Converting a decimal string to mpq_t

Vincent Lefevre vincent at vinc17.net
Thu May 1 10:49:54 CEST 2025


On 2025-04-29 07:30:22 +0200, Anders Andersson wrote:
> Neither will work, 0.1 is even an example in the mpf documentation:
> "The mantissa is stored in binary. One consequence of this is that
> decimal fractions like 0.1 cannot be represented exactly"
> 
> And as I hinted to in my original message, mpq_set_str does not handle
> floating point strings (according to its manual).

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

IMHO, it would be worth to support it in mpq_set_str, independently
of the notion of floating point.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)


More information about the gmp-discuss mailing list