-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
#1059: Add support for floating numbers separator #1093
Conversation
Thanks! You should add your name and email to NOTICE file first. |
It also makes sense to handle and throw error for invalid cases like: _123.0
123_.0
123._0
123.0_
0_0.0_0 |
++this.pos; | ||
} | ||
} | ||
} | ||
return parseFloat(text.substring(start, this.pos)); | ||
return parseFloat(text.substring(start, this.pos).replace(/_/g, '')); |
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.
Also we try to avoid RegExp
@@ -174,7 +174,11 @@ export function isWhiteSpace(c: i32): bool { | |||
|
|||
/** Tests if the specified character code is a valid decimal digit. */ | |||
export function isDecimalDigit(c: i32): bool { | |||
return c >= CharCode._0 && c <= CharCode._9; | |||
return c >= CharCode._0 && c <= CharCode._9 ; |
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.
nit: unnecessary space between semicolon and _9
|
||
while (this.pos < end) { | ||
let ch = text.charCodeAt(this.pos); | ||
if (!(isDecimalDigit(ch) || isDecimalSeparator(ch))) break; |
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 looks like it would accept ___123___123___.___123___
. Is that valid?
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.
Any thoughts on this? :)
Closing this PR as part of 2020 vacuum as it appears to be stale. Looks like not much was missing here to get it working, so feel free to open a new PR addressing the comments left so far. |
#1059: Add support for floating numbers separator