* object.c (rb_cstr_to_dbl): return 0.0 if hexadecimal and

baccheck is FALSE: Float("0x1p+0") works, but "0x1p+0".to_f
  doesn't. [ruby-dev:40650]

* util.c (ruby_strtod): allow hexdecimal integers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2010-04-01 04:32:43 +00:00
parent 2067e4eb30
commit 4d399f12d4
5 changed files with 45 additions and 15 deletions

View file

@ -1398,7 +1398,10 @@ class TestString < Test::Unit::TestCase
assert_equal([-0.0].pack('G'), [S("-0.0").to_f].pack('G'))
assert_equal([ 0.0].pack('G'), [S(" 0x0p+0").to_f].pack('G'))
assert_equal([-0.0].pack('G'), [S("-0x0p+0").to_f].pack('G'))
assert_equal(255.0, S("0Xff").to_f)
assert_equal(255.5, S("0Xff.8").to_f)
assert_equal(1.0, S("0X1.P+0").to_f)
assert_equal(1024.0, S("0x1p10").to_f)
assert_equal(1024.0, S("0x1p+10").to_f)
assert_equal(0.0009765625, S("0x1p-10").to_f)
assert_equal(2.6881171418161356e+43, S("0x1.3494a9b171bf5p+144").to_f)