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

Make String#to_f returns 0.0 for strings with leading underscores #1662

Closed
wants to merge 2 commits into from
Closed

Conversation

IPGlider
Copy link
Member

In Ruby 1.9.3

1.9.3p125 :001 > "_9".to_f
 => 0.0 

Before patch in Rubinius in 1.9 mode

rubinius-2.0.0dev :001 > "_9".to_f
 => 9.0 

After patch in Rubinius in 1.9 mode

rubinius-2.0.0dev :001 > "_9".to_f
 => 0.0 

@zaeleus
Copy link
Member

zaeleus commented Apr 12, 2012

I've been working on a more robust fix for this, especially since the current implementation has no concept of strictness (besides the regex match in Kernel#Float).

#1613

@IPGlider
Copy link
Member Author

Didn't saw someone was working on this, your solution seems a lot more complicated than mine. I will take a look, maybe we can coordinate.

@jfirebaugh
Copy link
Member

#1613 was merged. Sorry about the duplicated work @IPGlider.

@jfirebaugh jfirebaugh closed this Apr 18, 2012
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