-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
ext/bcmath: Supports scientific notation #18068
base: master
Are you sure you want to change the base?
ext/bcmath: Supports scientific notation #18068
Conversation
ext/bcmath/libbcmath/src/str2num.c
Outdated
{ | ||
const char *fractional_end = exponent_ptr; | ||
|
||
/* In scientific notation, the mantissa always has one integer digit. */ |
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.
This is false, e.g. 12e-3
should evaluate to 0.012
.
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.
I remember that this is what the ISO says, but I may be remembering it wrong...
I'll fix it
ext/bcmath/libbcmath/src/str2num.c
Outdated
goto fail; | ||
} | ||
|
||
/* Must be 1 <= mantissa < 10 */ |
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.
ditto
02f10fd
to
0f6e267
Compare
f93b82a
to
679e586
Compare
679e586
to
e3fa32c
Compare
related #17876
This probably requires an RFC, or at least a discussion on the mailing list, so I'll send an email once I've polished the code a bit more.
This change is to support code like this:
output:
I've used the
Number
class as an easy example to follow, but functions will accept these values as well.Benchmark
This change will make it a bit slower, but that may be tolerable.(This is just a prototype, so there is a possibility that it could be improved further.)
The performance seems to be about the same.
code:
result (first commit):
result (after commit 4)