diff --git a/src/styles/default/pretty.jl b/src/styles/default/pretty.jl index 3a3fda3ab..2b0107a7e 100644 --- a/src/styles/default/pretty.jl +++ b/src/styles/default/pretty.jl @@ -450,7 +450,7 @@ function p_literal( val = getsrcval(s.doc, s.offset:(s.offset+span(cst)-1)) if !is_str_or_cmd(cst) - if kind(cst) in KSet"Float Float32" && !startswith(val, "0x") + if kind(cst) in KSet"Float Float32" && !startswith(val, r"[+-]?0x") float_suffix = if (fidx = findlast(==('f'), val)) === nothing "" else diff --git a/test/issues.jl b/test/issues.jl index a9976c518..8ef39e5be 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -1953,4 +1953,15 @@ sf = "using Foo: (..)" @test fmt(s, 4, 100) == sf end + + @testset "921" begin + # These are floating point literals with hexadecimal significands. E.g. 0x1p1 is the + # float with with 0x1 as the significant and 1 as the exponent. + s = "0x1p1" + @test fmt(s) == s + s = "+0x1p1" + @test fmt(s) == s + s = "-0x1p1" + @test fmt(s) == s + end end