diff --git a/base/printf.jl b/base/printf.jl index 08f61adead2f0..36a82eb6f2b2f 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -1066,6 +1066,14 @@ function ini_hex(x::SmallFloatingPoint, symbols::Array{UInt8,1}) end end +function ini_hex(x::Integer) + len,pt,neg = decode_hex(x) + pt = (len-1)<<2 + len,pt,neg +end + +# not implemented +ini_hex(x::Integer,ndigits::Int) = throw(MethodError(ini_hex,(x,ndigits))) #BigFloat fix_dec(out, d::BigFloat, flags::ASCIIString, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) diff --git a/test/printf.jl b/test/printf.jl index 5d5a141676899..3315251d4437d 100644 --- a/test/printf.jl +++ b/test/printf.jl @@ -3,6 +3,8 @@ # printf # int @test (@sprintf "%d" typemax(Int64)) == "9223372036854775807" +@test (@sprintf "%a" typemax(Int64)) == "0x7.fffffffffffffffp+60" + for (fmt, val) in (("%i", "42"), ("%u", "42"), ("Test: %i", "Test: 42"), @@ -13,7 +15,10 @@ for (fmt, val) in (("%i", "42"), ("% i", " 42"), ("%+i", "+42"), ("%4i", " 42"), - ("%-4i", "42 ")) + ("%-4i", "42 "), + ("%a","0x2.ap+4"), + ("%20a"," 0x2.ap+4"), + ("%-20a","0x2.ap+4 ")) @test( @eval(@sprintf($fmt, 42) == $val)) end @@ -80,6 +85,8 @@ end # hex float @test (@sprintf "%a" 1.5) == "0x1.8p+0" +@test (@sprintf "%a" 1.5f0) == "0x1.8p+0" +@test (@sprintf "%a" big"1.5") == "0x1.8p+0" @test (@sprintf "%#.0a" 1.5) == "0x2.p+0" @test (@sprintf "%+30a" 1/3) == " +0x1.5555555555555p-2"