* sprintf.c (rb_str_format): support %a format. [ruby-dev:40650]

* missing/vsnprintf.c (BSD_vfprintf): ditto.

* missing/vsnprintf.c (cvt): ditto.

* util.c (BSD__hdtoa): added.  This is 2-clause BSDL licensed
  by David Schultz and from FreeBSD.

* LEGAL: add about hdtoa() in util.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2010-04-01 04:32:57 +00:00
parent 4d399f12d4
commit 12b2e16e21
6 changed files with 242 additions and 10 deletions

View file

@ -191,6 +191,19 @@ class TestSprintf < Test::Unit::TestCase
assert_equal(" Inf", sprintf("% 0e", 1.0/0.0), "moved from btest/knownbug")
end
def test_float_hex
assert_equal("-0x0p+0", sprintf("%a", -0.0))
assert_equal("0x0p+0", sprintf("%a", 0.0))
assert_equal("0x1p-1", sprintf("%a", 0.5))
assert_equal("0x1p+0", sprintf("%a", 1.0))
assert_equal("0x1p+1", sprintf("%a", 2.0))
assert_equal("0x1.193ea7aad030ap+0", sprintf("%a", Math.log(3)))
assert_equal("0X1.193EA7AAD030AP+0", sprintf("%A", Math.log(3)))
assert_equal("0x1p+10", sprintf("%a", 1024))
assert_equal("0x1.23456p+789", sprintf("%a", 3.704450999893983e+237))
assert_equal("0x1p-1074", sprintf("%a", 4.9e-324))
end
BSIZ = 120
def test_skip