How to define verbose output (for a polynomial)?

function Base.show(io::IO, p::Poly)
    coeffs = p.coeffs
    print(io, "x^", length(coeffs))
    for (i, c) in enumerate(reverse(coeffs))
        c == 0 && continue
        
        ex = length(coeffs) - i
        print(io, ' ', c > 0 ? '+' : '-', ' ')
        print(io, abs(round(c, sigdigits=2)))
        ex > 0 && print(io, 'x')
        ex > 1 && print(io, '^', ex)
    end
end
julia> Poly(rand(10).-0.5)
x^10 - 0.5x^9 - 0.47x^8 - 0.41x^7 + 0.16x^6 - 0.3x^5 - 0.14x^4 + 0.17x^3 + 0.25x^2 - 0.0077x + 0.19

julia> Poly(rand(10).^rand(10).-0.5)
x^10 - 0.17x^9 + 0.47x^8 + 0.49x^7 - 0.057x^6 - 0.17x^5 + 0.44x^4 + 0.27x^3 - 0.25x^2 + 0.041x - 0.09

julia> Poly(rand(10).-0.5)
x^10 + 0.2x^9 - 0.36x^8 + 0.0081x^7 + 0.12x^6 - 0.31x^5 + 0.37x^4 + 0.43x^3 - 0.093x^2 - 0.37x - 0.29

julia> Poly([1,-2,-3.165])
x^3 - 3.2x^2 - 2.0x + 1.0
2 Likes