Re: print() does output numbers in scientific notation violating JSON number spec
Bill Allombert <[email protected]> Thu, 18 Jan 2024 23:42:04 +0100
| Newsgroups | gmane.comp.mathematics.pari.devel |
|---|---|
| Message-ID | <ZampPPN7eNG/5LM7@seventeen> |
On Thu, Jan 18, 2024 at 11:09:49PM +0100, [email protected] wrote: > From latest JSON rfc: > > ? version > %2 = [2, 15, 4] > ? print(0.00001) > 1.0000000000000000000000000000000000000 E-5 > ? > > I use PARI/GP to write a JSON file, that is read by JavaScript/nodejs. > And that errors out on reading above number. > If I manually remove the space, "1.0000000000000000000000000000000000000E-5" > can be processed easily. You can do default(output,0) (\o0) ? \o0 ? print(0.00001) 1.0000000000000000000000000000000000000E-5 > Is there an option to make PARI/GP produce "0.00001" as output instead of > scientific representation? ? printf("%f",0.000000000000000000001) 0.0000000000000000000010000000000000000000000000000000000000 or even ? default(format,"f.38") ? print(0.00001) 0.000010000000000000000000000000000000000000 Cheers, Bill