siunitx icon indicating copy to clipboard operation
siunitx copied to clipboard

Exponential notation & uncertainties

Open jebej opened this issue 3 years ago • 3 comments

Hello, and thanks for the useful package!

I am trying to format numbers that are programatically generated, and wish to use an exponential notation as input, along with an uncertainty on that number. E.g., I am outputting a string of the form \num{5.22e+07 +- 7.11e+06}.

While it looks like the notation \num{9.99 +- 0.09} is supported (example from manual), the exponential form gives an error

! Package siunitx Error: Misplaced sign token '\pm '.

jebej avatar May 15 '21 00:05 jebej

I suppose this is related to the fact that, at the moment, numbers cannot be rounded when there is an uncertainty.

jebej avatar May 15 '21 00:05 jebej

It's nothing to do with rounding uncertainties (which will be available in v3). Really this comes down to what I've set up as a parser, based on what I've seen and what feels 'sensible'. Generally, people avoid giving different exponents for values and uncertainties, so 52.2 +- 7.11e+06 or similar, as this is equivalent to

(52.2 \pm 7.11) \times 10^{6}

Now, it's certainly possible to parse two exponents, but it's more work and will impact on performance (plus be mind bending for me). So I've got it down for a future enhancement.

josephwright avatar May 15 '21 12:05 josephwright

Thanks for your reply.

I mentioned rounding because, at the moment, one could write the full number and convert to scientific notation in siunitx, which works, except that without rounding all the digits get printed.

Any suggestion on how to handle this? (Other than waiting for v3.)

jebej avatar May 15 '21 13:05 jebej

I spot this is #208.

josephwright avatar Jul 28 '23 08:07 josephwright