ext/bcmath: Supports scientific notation - #18068
Draft
SakiTakamachi wants to merge 4 commits into
Draft
Conversation
ndossche
reviewed
Mar 15, 2025
| { | ||
| const char *fractional_end = exponent_ptr; | ||
|
|
||
| /* In scientific notation, the mantissa always has one integer digit. */ |
Member
There was a problem hiding this comment.
This is false, e.g. 12e-3 should evaluate to 0.012.
Member
Author
There was a problem hiding this comment.
I remember that this is what the ISO says, but I may be remembering it wrong...
I'll fix it
SakiTakamachi
commented
Mar 15, 2025
| goto fail; | ||
| } | ||
|
|
||
| /* Must be 1 <= mantissa < 10 */ |
SakiTakamachi
force-pushed
the
bcmath/support_scientific_notation
branch
3 times, most recently
from
March 16, 2025 08:27
02f10fd to
0f6e267
Compare
SakiTakamachi
force-pushed
the
bcmath/support_scientific_notation
branch
2 times, most recently
from
March 16, 2025 08:36
f93b82a to
679e586
Compare
SakiTakamachi
force-pushed
the
bcmath/support_scientific_notation
branch
from
March 16, 2025 08:43
679e586 to
e3fa32c
Compare
|
This is super useful, is there any reason why it wasn't merged? is there anything that could be done to help getting it merged? I see on the mailing list there wasn't really any objection, but it got stuck. |
Member
Author
|
@j3j5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Numberclass 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)