Skip to content

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

Closed
wants to merge 2 commits into from

3 participants

@IPGlider
Rubinius 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
Rubinius 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
Rubinius member

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
Rubinius 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
Something went wrong with that request. Please try again.