Skip to content

Commit 18604a0

Browse files
committed
Properly format -0.0
1 parent b502b76 commit 18604a0

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/fmtcore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ _digitchar(x::Integer, ::_Oct) = Char('0' + x)
6363
_digitchar(x::Integer, ::_Hex) = Char(x < 10 ? '0' + x : 'a' + (x - 10))
6464
_digitchar(x::Integer, ::_HEX) = Char(x < 10 ? '0' + x : 'A' + (x - 10))
6565

66-
_signchar(x::Number, s::Char) = x < 0 ? '-' :
66+
_signchar(x::Real, s::Char) = signbit(x) ? '-' :
6767
s == '+' ? '+' :
6868
s == ' ' ? ' ' : '\0'
6969

test/fmtspec.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fs = FormatSpec("d")
9595

9696
@test fmt("", 0.125) == "0.125"
9797
@test fmt("f", 0.0) == "0.000000"
98+
@test fmt("f", -0.0) == "-0.000000"
9899
@test fmt("f", 0.001) == "0.001000"
99100
@test fmt("f", 0.125) == "0.125000"
100101
@test fmt("f", 1.0/3) == "0.333333"

0 commit comments

Comments
 (0)