Skip to content
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

Number coerced from string and comparison issue #268

Closed
rwaldron opened this issue Mar 26, 2014 · 2 comments
Closed

Number coerced from string and comparison issue #268

rwaldron opened this issue Mar 26, 2014 · 2 comments

Comments

@rwaldron
Copy link
Contributor

Related to http://forum.espruino.com/conversations/772/#comment10693

Not sure where to look for this, hopefully you point me in the right direction, here's the example test case:

var ph = "8.55\r\n";
console.log(typeof +ph === "number"); // this is true
console.log(+ph === 8.55); // should be true, but result is false
@gfwilliams
Copy link
Member

Hmm. Thanks!

It's a strange one...

>+"8.55\r\n"==8.55
=true
>ph="8.55\r\n";+ph==8.55
=false

Actually turns out to be an issue with unary '+' not skipping over the variable name, so it was trying to convert 'ph' into a float. And it caused a memory leak too!

I'll commit the fix in a second. Sorry - by the time I found out where the issue was I'd as good as fixed it.

@rwaldron
Copy link
Contributor Author

Sorry - by the time I found out where the issue was I'd as good as fixed it.

No worries, just progress!

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

No branches or pull requests

2 participants