8000 df: fix incorrect rounding of size header by cakebaker · Pull Request #3530 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

df: fix incorrect rounding of size header #3530

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

Merged
merged 1 commit into from
May 20, 2022

Conversation

cakebaker
Copy link
Contributor

This PR fixes some incorrect rounding of the size header. For example, 10_001 was rounded up to 10.1kB instead of 11kB.

@@ -245,6 +245,7 @@ mod tests {
assert_eq!(to_magnitude_and_suffix(1001).unwrap(), "1.1kB");
assert_eq!(to_magnitude_and_suffix(1023).unwrap(), "1.1kB");
assert_eq!(to_magnitude_and_suffix(1025).unwrap(), "1.1kB");
assert_eq!(to_magnitude_and_suffix(10_001).unwrap(), "11kB");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in this case, the quotient of 10_001 and 1_000 is 10.001, which gets rounded up to 11 due to the new condition added to the code. Interesting.

@sylvestre sylvestre merged commit 9fb19c1 into uutils:main May 20, 2022
@cakebaker cakebaker deleted the fix_size_header_rounding branch May 20, 2022 08:37
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 this pull request may close these issues.

3 participants
0