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

rounding zero with round-mode=figures #630

Open
quantenschaum opened this issue Nov 25, 2022 · 4 comments
Open

rounding zero with round-mode=figures #630

quantenschaum opened this issue Nov 25, 2022 · 4 comments

Comments

@quantenschaum
Copy link

The following code produces unexpected result

\sisetup{round-precision=3,round-mode=figures}
actual \num{0.000000} \num{1.000000} -- expected \num{0.00} \num{1.00}

renders as

image

There are too many trailing 0s when 0 is rounded. Using round-mode=places works as expected.

@josephwright
Copy link
Owner

I'm not sure what the 'expected' output is here: arguably it's undefined. I can for example see an argument for 0 (dropping all digits) as well as for the current behaviour. I'm not at all sure about the output you suggest: how do you decide it's 'right'?

@quantenschaum
Copy link
Author

Well, I did not decide that it is right or wrong, I said it is "unexpected". Why? Simply because the 1 is rendered as 1.00 with 3 figures and I expected the 0 to be rendered with 3 figures (or maybe less, but not more than 3 as requested) as well. Trailing zeroes are removed from the 1 but not from the 0. Why?

And, when round-precision=2,round-mode=places is used, it behaves as expected. It renders 0.00 1.00.

I can imagine, that other users stumble upon this issue and the majority of them shares my expectation.

@josephwright
Copy link
Owner

What's important here is we are rounding to significant figures. So we get 1.00 because the 1 is a significant figure. If the input was 0.01000, we'd get 0.0100 as output. In the case 0.00000, there are no significant figures at all. So the output is really undefined: like I said, I can see an argument for 'no change' or `just zero'.

@josephwright
Copy link
Owner

Perhaps related: #206

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

No branches or pull requests

2 participants