Skip to content

Unit measurements shouldn't convert from XiB to XB #16

Closed

Description

@mmstick
let block_sectors = 1953458176;
let size = ByteSize::kib(block_sectors / 2);
println!("{}", size);

Expected Output:

931.48 GiB

Actual Output:

1000.2 GB

Activity

  1. hyunsik commented on Oct 30, 2018

    @hyunsik
    Member

    Your request makes sense for me. In terms of implementation, we will be able to keep the unit as a kind of Enum and use the Enum type to represent the original input unit. But, it will cause the different behavior of the current library. So, let me think about more if there is a better option.

  2. loyd commented on Dec 8, 2024

    @loyd

    I hope it won't affect the ByteSize representation (I think it should be a lightweight wrapper around usize). However, a new wrapper, ByteSizeWithUnit, can be introduced to store `size' and the initial unit if it's useful.

    However, simple use IEC by default (#37) covers 99% of use cases, so an additional structure is redundant.

  3. tisonkun commented on Jun 7, 2026

    @tisonkun

    The most simple way is to display ByteSize, without .display(), in bytes.

    Thus,

    let block_sectors = 1953458176;
    let size = ByteSize::kib(block_sectors / 2);
    println!("{}", size);
    
    // prints 1953458176 B

    Due to #135 I may try to create a logical fork of this crate to demonstrate some ideas here :D

    Here is the crate: https://github.com/fast/bsize

  4. robjtede commented on Jul 31, 2026

    @robjtede
    Member

    afaict this issue is address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions