-
Notifications
You must be signed in to change notification settings - Fork 8k
Use -1 "precision" in gen_stub.php #8734
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
Conversation
| * @cname M_E | ||
| */ | ||
| const M_E = 2.7182818284590452354; | ||
| const M_E = 2.718281828459045; |
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.
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.
why is M_E declared here and no other math constants?
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.
Oh, indeed, that looks fishy. We use the definitions provided by libc, if available, and only define the macros ourselves otherwise. There is nothing special about M_E compared to the other constants (like M_PI).
However, given that we already go to great lengths to have portable floating point arithmetic, it may not be the best idea to rely on definitions provided by libc.
| { | ||
| REGISTER_DOUBLE_CONSTANT("M_E", M_E, CONST_CS | CONST_PERSISTENT); | ||
| ZEND_ASSERT(M_E == 2.7182818284590451); | ||
| ZEND_ASSERT(M_E == 2.718281828459045); |
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.
needed as compared as string here, https://3v4l.org/9C9LV
| Math constants | ||
| --INI-- | ||
| precision=14 | ||
| precision=-1 |
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.
we want to assert the full precision, double is used for both x86/x64 build
| --TEST-- | ||
| Test for pre-defined math constants | ||
| --INI-- | ||
| precision=14 |
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.
var_dump uses (correctly) always the full/-1 precision
| M_SQRT1_2 : 0.707106[0-9]* | ||
| M_SQRT3 : 1.732050[0-9]* | ||
| --EXPECT-- | ||
| M_E : 2.718281828459045 |
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.
on all platforms, the output should be strictly the same
|
@bwoebi, @kocsismate, what do you think about this PR? |
|
@bwoebi @kocsismate @cmb69 this PR sits here for a long time but is finished, can you please review? |
|
This looks reasonable, but needs a rebase. |
|
rebased |
|
Thank you! |
https://3v4l.org/FkrAj - only
-1results in the shortest 64-bit IEEE 754 floating-point representation possible,17can print more unneeded digitsalso improve two math constants tests by asserting the exact values