boostorg / multiprecision

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

boost::multiprecision::cpp_int leading zeros parsing bug #612

Closed ohhmm closed 3 months ago

ohhmm commented 3 months ago

boost::multiprecision::cpp_int("000144") parsed into value 100. See some details here: https://github.com/ohhmm/openmind/blob/28b9ed5d55bf1766606442cc34689ee0c32671e7/omnn/math/test/Integer_test.cpp#L59

ckormanyos commented 3 months ago

boost::multiprecision::cpp_int("000144") parsed into value 100.

Should this parse as an octal base?

mborland commented 3 months ago

boost::multiprecision::cpp_int("000144") parsed into value 100.

Should this parse as an octal base?

I think anything of the form 0144 should be octal, but 000144 are base-10 leading zeros that need to get stripped out. See the linked PR.

ckormanyos commented 3 months ago

as an octal base?

Because then the expected answer is: $8{\times}8+4{\times}8+4=100$

ohhmm commented 3 months ago

Hi. This doesn't look expected to me. Leading zeros hardly should change base of parsing. But since it is C standard compliant, lets close this ticket.