-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--TEST-- | ||
Math constants | ||
--INI-- | ||
precision=14 | ||
precision=-1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
--FILE-- | ||
<?php | ||
$constants = array( | ||
|
@@ -27,21 +27,21 @@ foreach($constants as $constant) { | |
printf("%-10s: %s\n", $constant, constant($constant)); | ||
} | ||
?> | ||
--EXPECTREGEX-- | ||
M_E : 2.718281[0-9]* | ||
M_LOG2E : 1.442695[0-9]* | ||
M_LOG10E : 0.434294[0-9]* | ||
M_LN2 : 0.693147[0-9]* | ||
M_LN10 : 2.302585[0-9]* | ||
M_PI : 3.141592[0-9]* | ||
M_PI_2 : 1.570796[0-9]* | ||
M_PI_4 : 0.785398[0-9]* | ||
M_1_PI : 0.318309[0-9]* | ||
M_2_PI : 0.636619[0-9]* | ||
M_SQRTPI : 1.772453[0-9]* | ||
M_2_SQRTPI: 1.128379[0-9]* | ||
M_LNPI : 1.144729[0-9]* | ||
M_EULER : 0.577215[0-9]* | ||
M_SQRT2 : 1.414213[0-9]* | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. on all platforms, the output should be strictly the same |
||
M_LOG2E : 1.4426950408889634 | ||
M_LOG10E : 0.4342944819032518 | ||
M_LN2 : 0.6931471805599453 | ||
M_LN10 : 2.302585092994046 | ||
M_PI : 3.141592653589793 | ||
M_PI_2 : 1.5707963267948966 | ||
M_PI_4 : 0.7853981633974483 | ||
M_1_PI : 0.3183098861837907 | ||
M_2_PI : 0.6366197723675814 | ||
M_SQRTPI : 1.772453850905516 | ||
M_2_SQRTPI: 1.1283791670955126 | ||
M_LNPI : 1.1447298858494002 | ||
M_EULER : 0.5772156649015329 | ||
M_SQRT2 : 1.4142135623730951 | ||
M_SQRT1_2 : 0.7071067811865476 | ||
M_SQRT3 : 1.7320508075688772 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
--TEST-- | ||
Test for pre-defined math constants | ||
--INI-- | ||
precision=14 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
--FILE-- | ||
<?php | ||
echo "M_E= "; | ||
|
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.
https://3v4l.org/MMg8H
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 (likeM_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.