-
Notifications
You must be signed in to change notification settings - Fork 144
Fix float printing #676
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
base: master
Are you sure you want to change the base?
Fix float printing #676
Conversation
Does |
I have been thinking that the second parameter in #StartFloat should be not just a number, but MZV=number. This for when the future needs other parameters as well. It also makes things more readable. What do you think?
… On 20 Jun 2025, at 16:22, jodavies ***@***.***> wrote:
jodavies
left a comment
(form-dev/form#676)
<#676 (comment)>
Does SetupMZVTables need the same change? In that function there is some weight dependence on the precision that is used; I wonder if it is not easier to just allocate everything at the same, maximally-required precision? Then the logic to set the precision can all move to DoStartFloat and the multiple calls to SetFloatPrecision could all be removed?
—
Reply to this email directly, view it on GitHub <#676 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABJPCESVHPNQX3GF2N25X333EQKJDAVCNFSM6AAAAAB7YM3LGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOJRHAYTINBYGQ>.
You are receiving this because you are subscribed to this thread.
|
That sounds reasonable. Also a way to specify precision in digits rather than bits?
for example. Or do b and d look too similar there? I also wonder: why can the regular |
@jodavies, this can indeed use some cleaning up, see the following example:
vs
The last digit changed if we added a few more bits of precision. @vermaseren, I also like the idea to be specific that the weights are for the MZVs. Maybe indeed also go with @jodavies suggestion to specify the precision in either bits or digits. |
I don’t think the b and d are a problem. Concerning the aux floats, my attitude was to do this myself, to allow me to understand what is happening. Of course, now we know what works, we can make variations, because now it means changing one thing at a time.
… On 20 Jun 2025, at 16:39, jodavies ***@***.***> wrote:
jodavies
left a comment
(form-dev/form#676)
<#676 (comment)>
That sounds reasonable. Also a way to specify precision in digits rather than bits?
#startfloat 50b,MZV=0
#startfloat 50d,MZV=0
for example. Or do b and d look too similar there?
I also wonder: why can the regular mpf_init function not be used to set up the aux floats? Then everything should "just work" at the precision that is requested?
—
Reply to this email directly, view it on GitHub <#676 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABJPCEUAJMIPRTWELQSSSSD3EQMJRAVCNFSM6AAAAAB7YM3LGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOJRHA3DKNRYGQ>.
You are receiving this because you commented.
|
I see that the tests that printed some of the constants like |
I changed |
assert result("PI6") =~ expr("1.7724538509055160273e+00") | ||
assert result("EE1") =~ expr("2.7182818284590452354e+00") | ||
assert result("EE2") =~ expr("8.5397342226735670654e+00") | ||
assert result("EM1") =~ expr("5.772156649015328606e-01") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense that there is a digit less here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean for EM1
specific or for all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For EM1 specifically: the rest all have the same number of digits. The next would be a 1
, from rounding 07
, or? Does the conversion truncate rather than round (and then FORM cuts the trailing 0)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the next digits, one has 5.77215664901532860606e-01
. So it looks like it got truncated: 60606
becomes 6060
by gmp_snprintf
in PrintFloat. Then the parsing of FORM drops the last 0. So in total, one gets one digit less compared to the other examples in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more observation: running this test with one more bit (so #StartFloat 65
), EE1
and EM1
change (the rest is unchanged), that is
EE1 =
2.7182818284590452353e+00;
EM1 =
5.7721566490153286061e-01;
The rounding for EM1
seems now more logical to me, whereas for EE1
the previous rounding (with 64 bits) seemed more logical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I think this is the expected behaviour of MPFR_RNDN
.
refactor: use GMP's mpf_init etc. to set up the aux floats and MZVTables. test: updated the evaluate_symbol tests according to the fixed float printing.
- Removed double SetFloatPrecision call. Now only called once from DoStartFloat. - Fixed precision handling in SimpleDelta and SimpleDeltaC. - Adjusted printed digits to avoid overprinting from gmp_snprintf. test: adjusted the test evaluate_symbol accordingly and added two tests for the evaluation of MZV's.
For the new test that evaluates all MZVs up to weight 6, we could consider increasing the weight. On my laptop, evaluating up to weight 10 only takes about 0.25 seconds. |
This fixes the float printing issue
that resulted in
The correct result is now
Furthermore set the default MZV weight
MAXWEIGHT
to 0 instead of 40.