Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LN_KIB / LN_KB are backwards #26

Open
mstange opened this issue Jun 12, 2021 · 0 comments · May be fixed by #38
Open

LN_KIB / LN_KB are backwards #26

mstange opened this issue Jun 12, 2021 · 0 comments · May be fixed by #38

Comments

@mstange
Copy link

mstange commented Jun 12, 2021

https://github.com/hyunsik/bytesize/blob/02822917468b14b6daa5bd76c0522a4f06a1188e/src/lib.rs#L63-L64

The two base values are backwards. This leads to the selection of the wrong unit; values larger than 1000 or lower than 1.0 can be displayed, e.g. "1090.0 GB" or "0.9 TiB".

use bytesize::ByteSize;

fn main() {
    println!("{}", ByteSize::gib(940).to_string_as(true));
    println!("{}", ByteSize::gb(940).to_string_as(false));
    println!("{}", ByteSize::gib(1090).to_string_as(true));
    println!("{}", ByteSize::gb(1090).to_string_as(false));
}

// Output:             Expected output:
// 0.9 TiB             940.0 GiB
// 940.0 GB            940.0 GB
// 1.1 TiB             1.1 TiB
// 1090.0 GB           1.1 TB
ChanTsune added a commit to ChanTsune/bytesize that referenced this issue Aug 24, 2023
ChanTsune added a commit to ChanTsune/bytesize that referenced this issue Aug 24, 2023
Co-Authored-By: Adam Cutler <[email protected]>
@Andrew15-5 Andrew15-5 linked a pull request Oct 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant