boostorg / multiprecision

Boost.Multiprecision
Boost Software License 1.0
188 stars 112 forks source link

Remove leading zeros from base-10 numbers #614

Closed mborland closed 3 months ago

mborland commented 3 months ago

Currently we assume that anything with a leading 0 is in octal format. Change to where octal has to be 0 followed by a non-zero number. If the format does not meet that requirement for octal than remove any and all leading zeros.

Closes: #612

ckormanyos commented 3 months ago

Change to where octal has to be 0 followed by a non-zero number.

Ah now I get it.

mborland commented 3 months ago

@jzmaddock Any issue with this change? It would technically be a breaking change, but I think the new behavior is less surprising.

jzmaddock commented 3 months ago

Any issue with this change? It would technically be a breaking change, but I think the new behavior is less surprising.

I do worry about this, consider a block of formatted numbers:

0001
0002
0003
...
0099
0100

We start off as decimal, and then there is a step change to octal when we get to "0100" which seems even worse to me?

mborland commented 3 months ago

Godbolt says leading zeros is still octal: https://godbolt.org/z/7Kcahjh67. Since the original ticket is closed I'll just close this too.

ckormanyos commented 3 months ago

start off as decimal, and then there is a step change to octal

Oh geez I actually had that one last century. It took 3 days to resolve. But now that I reflecrt (which I had entirely forgotten) so is the spec.