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

[WIP] Float tests #492

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

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
Owner

vermaseren commented Mar 11, 2024 via email

@jodavies
Copy link
Collaborator Author

The ouput is truncated here:

n = gmp_snprintf((char *)(AO.floatspace),AO.floatsize,"%.*Fe",numdigits,aux4);

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

fllor commented Jun 3, 2024

I found the bug printing routine. One has to change

form/sources/float.c

Lines 962 to 963 in e99543a

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

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
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.

4 participants