Skip to content

[WIP] Float tests #492

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[WIP] Float tests #492

wants to merge 1 commit into from

Conversation

jodavies
Copy link
Collaborator

Here I have added the example from the Madrid workshop slides.

@jodavies
Copy link
Collaborator Author

To do: why does F1 print with e+0 and F2 without? Which is the desired behaviour?

@tueda
Copy link
Collaborator

tueda commented Mar 11, 2024

Well, if we put it into example.frm (examples in the manual), then should we put this example into the manual with the following comment?

% THIS EXAMPLE IS PART OF THE TESTSUITE. CHANGES HERE SHOULD BE APPLIED THERE AS
% WELL! (Float_1)

@jodavies
Copy link
Collaborator Author

jodavies commented Mar 11, 2024

The e+0 is a bug actually: F1 should be e+3 (easy to see from the rational form of F1/F2).

Edit: digits wise, I confirmed that there is agreement with PolyLogTools in Mathematica.

@vermaseren
Copy link
Collaborator

vermaseren commented Mar 11, 2024 via email

@jodavies
Copy link
Collaborator Author

The ouput is truncated here:
https://github.com/vermaseren/form/blob/e99543ad939ef823f5e8db0678aa18028e7de707/sources/float.c#L950

If you ask for numdigits+1 then you get e+03 (and now a bare e appears on the output of F2). I think the required buffer size for the print can be found by calling gmp_snprintf(NULL,0,"%.*Fe",numdigits,aux4) first.

@jodavies
Copy link
Collaborator Author

I was too hasty there, the issue is in the post-processing code that follows. As I understand it you would like the following:

  1. truncate trailing zeros
  2. don't print "e+00"

Is this correct?

@fllor
Copy link
Contributor

fllor commented Jun 3, 2024

I found the bug printing routine. One has to change

https://github.com/vermaseren/form/blob/e99543ad939ef823f5e8db0678aa18028e7de707/sources/float.c#L962-L963
to

while ( n2 < n ) { *s1++ = *s2++; n2++; }
n -= (n2-n1);

This will correctly truncate all trailing zeros, but leave the exponent intact. Removing "e+00" is not part of this routine.

@jodavies
Copy link
Collaborator Author

jodavies commented Jun 3, 2024

OK, please add the fix in your branch and lets see if the valgrind errors are gone. I can rebase this on top of your changes later.

@tueda
Copy link
Collaborator

tueda commented Jun 3, 2024

By the way, why is the precision of printed numbers strongly influenced by the maximum weight?

#StartFloat 50,6
L F = 1/3;
tofloat;
P;
.end
   F =
      3.3e-01;

@jodavies
Copy link
Collaborator Author

jodavies commented Jun 4, 2024

The final digit of pi is also not rounded correctly, is it understood why this is?

@jodavies jodavies added this to the v5 milestone Nov 6, 2024
@jodavies
Copy link
Collaborator Author

Updated after #532. But @tueda 's question remains: there is some interaction between the precision and weight parameters. The precision is in bits, and is modified by SetFloatPrecision called by SetupMPFTables and then again by SetupMZVTables. If AC.DefaultPrecision grows enough the printing changes...

@coveralls
Copy link

coveralls commented May 27, 2025

Coverage Status

coverage: 49.801% (+0.5%) from 49.264%
when pulling 7f9388f on jodavies:float-tests
into 915a14d on vermaseren:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants