Skip to content

printf MethodError with "append_nine_digits" #52749

@stevengj

Description

@stevengj

This seems like a bug:

julia> using Printf

julia> @printf("%.60g", 1.38e-23)
1.3800000000000000600105824657340787992976609667826426243954e-23
julia> @printf("%.160g", 1.38e-23)
ERROR: MethodError: no method matching append_nine_digits(::Int64, ::Vector{UInt8}, ::Int64)

Closest candidates are:
  append_nine_digits(::Unsigned, ::Any, ::Int64)
   @ Base intfuncs.jl:815

Stacktrace:
 [1] writeexp(buf::Vector{…}, pos::Int64, v::Float64, precision::Int64, plus::Bool, space::Bool, hash::Bool, expchar::UInt8, decchar::UInt8, trimtrailingzeros::Bool)
   @ Base.Ryu ./ryu/exp.jl:113
 [2] writeexp(buf::Vector{…}, pos::Int64, v::Float64, precision::Int64, plus::Bool, space::Bool, hash::Bool, expchar::UInt8, decchar::UInt8, trimtrailingzeros::Bool)
   @ Base.Ryu ./ryu/exp.jl:4 [inlined]
 [3] fmt
   @ ~/Documents/Code/julia/usr/share/julia/stdlib/v1.11/Printf/src/Printf.jl:531 [inlined]
 [4] fmt
   @ ~/Documents/Code/julia/usr/share/julia/stdlib/v1.11/Printf/src/Printf.jl:313 [inlined]
 [5] format
   @ ~/Documents/Code/julia/usr/share/julia/stdlib/v1.11/Printf/src/Printf.jl:834 [inlined]
 [6] format(io::Base.TTY, f::Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'g'}}}}, args::Float64)
   @ Printf ~/Documents/Code/julia/usr/share/julia/stdlib/v1.11/Printf/src/Printf.jl:935

It looks like the Unsigned type qualifier was added by @vtjnash to append_nine_digits in #51273, so it's a pretty recent problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviordisplay and printingAesthetics and correctness of printed representations of objects.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions