Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate numbers printed by Format float <number> #439

Closed
tueda opened this issue Mar 22, 2023 · 3 comments
Closed

Inaccurate numbers printed by Format float <number> #439

tueda opened this issue Mar 22, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@tueda
Copy link
Collaborator

tueda commented Mar 22, 2023

Format float <number> prints the output in the floating-point notation up to 100 digits. But for the following example, the precision somehow saturates at N ~ 91:

L F =
16020477561421692952487130706964323462700663188794863242830247036589271925412774344912016394073406219
/
9739282494232553676474274187877549323464250480060655692338461020488417652652504432571071309828391142
;

#ifdef `N'
Format float, `N';
#endif
Format 255;
Print +s;
.end
N     result
80    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008
81    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087
82    1.644934066848226436472415166646025189218949901206798437735558229370007470403200873
83    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738
84    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087383
85    1.644934066848226436472415166646025189218949901206798437735558229370007470403200873833
86    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336
87    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087383362
88    1.644934066848226436472415166646025189218949901206798437735558229370007470403200873833628
89    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336289
90    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087383362890
91    1.644934066848226436472415166646025189218949901206798437735558229370007470403200873833628900
92    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336289007
93    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087383362890079
94    1.644934066848226436472415166646025189218949901206798437735558229370007470403200873833628900792
95    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336289007920
96    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087383362890079200
97    1.644934066848226436472415166646025189218949901206798437735558229370007470403200873833628900792002
98    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336289007920025
99    1.64493406684822643647241516664602518921894990120679843773555822937000747040320087383362890079200256
100   1.644934066848226436472415166646025189218949901206798437735558229370007470403200873833628900792002564
exact 1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336289006197587053040043190...

I guess both the numerator and denominator would be approximated by N-digit integers. But then I expect that the result should be accurate up to ~ N digits. Indeed, if I manually approximate the expression by 95-digit integers (for N = 95), then the result is accurate up to 95 digits:

* manually approximated (note the last 0s in the digits)
L F = 
16020477561421692952487130706964323462700663188794863242830247036589271925412774344912016394073000000
/
9739282494232553676474274187877549323464250480060655692338461020488417652652504432571071309828300000
;
Format float, 95;
Format 255;
Print +s;
.end
95    1.6449340668482264364724151666460251892189499012067984377355582293700074704032008738336289006197

The first example must print these digits for N = 95 without the manual approximation.

@vermaseren
Copy link
Owner

vermaseren commented Mar 22, 2023 via email

@vermaseren
Copy link
Owner

By now I have checked all routines that called DivLong with such arguments and the only ones I could find dealt with modulus calculus which for most cases involves only single WORD precision for the denominator and hence that would never use the GMP. It looks like probably no major accidents have happened.

@tueda tueda added the bug Something isn't working label Mar 23, 2023
@tueda
Copy link
Collaborator Author

tueda commented Mar 23, 2023

Thanks! Indeed 361e037 fixes this issue and now the example correctly gives 1.644934066...6289006197 for N = 95.

@tueda tueda closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants