Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upfix result of String.toFloat "." (#336) #343
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 11, 2015
Member
Thanks!
I wonder if this is how we should be implementing this in the first place. I don't really remember why I chose this route. Maybe it would be better to use a regex like [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? or to just put parseFloat in a try block and trust that it'll do the right thing?
I also wonder why parseFloat('.') == NaN in JavaScript. Can you try to find out why that is true?
|
Thanks! I wonder if this is how we should be implementing this in the first place. I don't really remember why I chose this route. Maybe it would be better to use a regex like I also wonder why |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pisys
Aug 12, 2015
Contributor
parseFloat is less strict than the current implementation. It allows whitespaces, exponents, and only demands a prefix of the input string to be a float. Since "." is not a Float parseFloat returns NaN!
However, parseFloat can also parse "Infinity", which is a Number in JavaScript but not in Elm! So I discourage the mere wrapping of parseFloat until there is a explicit Infinity thing in Elm, such as x = Infinity (instead of x = 0/0).
|
parseFloat is less strict than the current implementation. It allows whitespaces, exponents, and only demands a prefix of the input string to be a float. Since "." is not a Float parseFloat returns NaN! However, parseFloat can also parse "Infinity", which is a Number in JavaScript but not in Elm! So I discourage the mere wrapping of parseFloat until there is a explicit Infinity thing in Elm, such as |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 19, 2016
Contributor
How is this pull request related to https://github.com/elm-lang/core/pull/342?
|
How is this pull request related to https://github.com/elm-lang/core/pull/342? |
This was referenced Jan 19, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 21, 2016
Contributor
I'm closing this for now, since it appears to be overridden by https://github.com/elm-lang/core/pull/342. Please re-open with comment if you disagree.
|
I'm closing this for now, since it appears to be overridden by https://github.com/elm-lang/core/pull/342. Please re-open with comment if you disagree. |
pisys commentedAug 11, 2015
which is now a Err instead of Ok NaN.
Also added tests for String conversion.