strconv: fix of atoi() and its tests.#23737
Merged
Merged
Conversation
|
Connected to Huly®: V_0.6-22154 |
spytheman
reviewed
Feb 16, 2025
spytheman
reviewed
Feb 16, 2025
spytheman
reviewed
Feb 16, 2025
Delta456
reviewed
Feb 16, 2025
…th implementation present at the moment.
…re specific errors messages. Use min_int and max_int defined in builtin.
spytheman
reviewed
Feb 16, 2025
spytheman
reviewed
Feb 16, 2025
JalonSolov
reviewed
Feb 16, 2025
JalonSolov
reviewed
Feb 16, 2025
Contributor
|
To me, the PR looks good, and ready to merge, after the CI jobs pass. |
spytheman
approved these changes
Feb 16, 2025
JalonSolov
reviewed
Feb 16, 2025
Co-authored-by: JalonSolov <JalonSolov@gmail.com>
Co-authored-by: JalonSolov <JalonSolov@gmail.com>
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.
Revwrite of atoi(s string) !int
Positive points:
-Tests are more complete.
-Exact 32bits overflow/underflow
-Corrected x = (x * 10) + c (may fail on *10 and + c operation)
-Follow as much as possible V scanner with underscores (https://discord.com/channels/592103645835821068/592114487759470596/1339276917383364683).
-Underscore are supported whatever the lenght of the input string.
-Error messages are very similar to original atoi()
-Doesn't rely any more on parse_int() (https://discord.com/channels/592103645835821068/592114487759470596/1340260943325691904).
Drawback:
-Still considers type int as 32bits as stated in documentation (may change in the future).
-On previous implementation, atoi() called parse_int() method if string length was greater than 10 chars. Parse_int() supports different radix than 10, unlike atoi. Code relying on this behaviour may be broken.