josephwright / siunitx

A comprehensive (SI) units package for LaTeX
LaTeX Project Public License v1.3c
353 stars 26 forks source link

Uncertainty rounding for both uncertainties and non-uncertainties in one. #654

Open josephwright opened 1 year ago

josephwright commented 1 year ago

Split out from #652. Currently a user has to specify if they want the rounding to occur with uncertainty or figures. It would be very convenient if there was another rounding option smart that takes into consideration whether an uncertainty was provided. I could do something like:

\sisetup{ uncertainty-mode = separate, exponent-mode = scientific, round-mode = smart, }
\SI[round-precision=4]{3031523.20585698(74336.4927580466)}{\meter\per\second}

to get the equivalent of. Similarly

\SI{round-precision=3}{299 792 458 }{\meter\per\second} 

As it stands currently, if we use \sisetup{round-mode=uncertainty}, the second number fails to round to 3 significant digits and just prints out the same value.

josephwright commented 1 year ago

I'm not so keen on this, as the meaning of the two types of rounding is very different. It's very likely that you need different rounding precision for the two cases. Also, rounding is really mainly for table columns, and it's very unlikely the data will be that heterogeneous. So whilst I won't close, I'm not minded to implement here.

Gerald-Meyers commented 1 year ago

So is siunitx primarily inteded for table formatting (of homogeneous data)? I have been using it to format python output (without uncertainties) for single value outputs.

josephwright commented 1 year ago

@Gerald-Meyers Tables aren't the core aim for me of siunitx, but there is a lot of usage for tables. Of course, every user is different, but the main use case I imagine for rounding is reading external data files for automatic formatting. For one-off values in the document body, most people will I think simply type them in and so round appropriately themselves. Most automatic value reading will be for tables. But that doesn't mean people can't use it for whatever.