Converting a decimal string to mpq_t

Torbjörn Granlund tg at gmplib.org
Thu May 1 11:59:21 CEST 2025


Vincent Lefevre <vincent at vinc17.net> writes:

  0.1 is a notation that was used in math before floating point existed:
  https://en.wikipedia.org/wiki/Decimal#History

What formats should we support around any "/"?

{0x}d+{E}
{0x}d+.d*{E}
{0x}d*.d+{E}

E in turn is [eE]{+-}d+

{} means optional
[] is a range
d is a digit in the base

I cannot recall if we let a leading 0 to mean octal.  If we don't,
allowing it would create a compatibility problem.

Some examples (assuming the argument "base" is 0):

0.1
.1
1.
0x0.f   if a mantissa is in hex, the part after a base point should have the same base
17

0.1e1
0.1e+1
0.1e-1


.       disallowed: at least one digit is needed
1.f     disallowed unless the "base" argument >= 16

How about the base of an exponent?  E.g., should it also be hex if
"base" is hex?

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-discuss mailing list