Skip to content

Commit

Permalink
Use mpfr function to get meaningful decimal digits in "format"
Browse files Browse the repository at this point in the history
  • Loading branch information
d-torrance committed Nov 7, 2024
1 parent 6a1ee7c commit a74365c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion M2/Macaulay2/d/gmp1.d
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export format(
ng := sign(x);
if isinf(x) then return array(string)(if ng then "-" else "","infinity");
if isnan(x) then return array(string)(if ng then "-" else "","NotANumber");
meaningful := int(floor(precision(x) / log2ten)) + 1;
meaningful := Ccode(int,
"mpfr_get_str_ndigits(", base, ", ", precision(x), ")");
if s == 0 || s > meaningful then s = meaningful; -- print at most the "meaningful" digits
sgn := "";
if ng then (
Expand Down

0 comments on commit a74365c

Please sign in to comment.