Skip to content

Conversation

@koluch
Copy link

@koluch koluch commented Feb 5, 2020

#1059: Add support for floating numbers separator

@MaxGraey
Copy link
Member

MaxGraey commented Feb 5, 2020

Thanks! You should add your name and email to NOTICE file first.

@MaxGraey
Copy link
Member

MaxGraey commented Feb 5, 2020

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

}
}
return parseFloat(text.substring(start, this.pos));
return parseFloat(text.substring(start, this.pos).replace(/_/g, ''));
Copy link
Member

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

/** 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 ;
Copy link
Member

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;
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts on this? :)

@dcodeIO
Copy link
Member

dcodeIO commented May 25, 2020

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.

@dcodeIO dcodeIO closed this May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants