| Bill Allombert on Sat, 01 Nov 2025 23:18:57 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: guarantees on digits of floating point values |
On Sat, Nov 01, 2025 at 08:11:06PM +0100, Ruud H.G. van Tol wrote: > > As a test, I checked 1000021 digits of exp(1), > > my(N=10^6+21); localprec(N); exp(1) * 10^(N-1)\1 > > against https://apod.nasa.gov/htmltest/gifcity/e.1mil > and all digits matched. :) > > Is there a guarantee in the documentation about such? This is difficult due to rounding and base conversion. For example: ? my(N=173); localprec(N); exp(1) * 10^(N-1)\1 %32 = 27182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279435 ? my(N=174); localprec(N); exp(1) * 10^(N-1)\1 %33 = 271828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349 To avoid this, you need to be much more careful. Cheers, BIll.