@@ -5,7 +5,7 @@ module FixedPointNumbers
55using Base: reducedim_initarray
66
77import Base: == , < , <= , - , + , * , / , ~ , isapprox,
8- convert, promote_rule, show, showcompact, isinteger, abs, decompose,
8+ convert, promote_rule, show, isinteger, abs, decompose,
99 isnan, isinf, isfinite,
1010 zero, oneunit, one, typemin, typemax, realmin, realmax, eps, sizeof, reinterpret,
1111 float, trunc, round, floor, ceil, bswap,
@@ -101,11 +101,10 @@ function showtype(io::IO, ::Type{X}) where {X <: FixedPoint}
101101 io
102102end
103103function show (io:: IO , x:: FixedPoint{T,f} ) where {T,f}
104- showcompact (io, x )
105- showtype (io, typeof (x))
104+ show (io, round ( convert (Float64,x), digits = ceil (Int,f / _log2_10)) )
105+ get (io, :compact , false ) || showtype (io, typeof (x))
106106end
107107const _log2_10 = 3.321928094887362
108- showcompact (io:: IO , x:: FixedPoint{T,f} ) where {T,f} = show (io, round (convert (Float64,x), digits= ceil (Int,f/ _log2_10)))
109108
110109function Base. showarg (io:: IO , a:: Array{T} , toplevel) where {T<: FixedPoint }
111110 toplevel || print (io, " ::" )
@@ -176,8 +175,8 @@ scaledual(b::Tdual, x::Union{T,AbstractArray{T}}) where {Tdual <: Number,T <: Fi
176175 n = 2 ^ (8 * sizeof (T))
177176 bitstring = sizeof (T) == 1 ? " an 8-bit" : " a $(8 * sizeof (T)) -bit"
178177 io = IOBuffer ()
179- showcompact (io , typemin (T)); Tmin = String (take! (io))
180- showcompact (io , typemax (T)); Tmax = String (take! (io))
178+ show ( IOContext (io, :compact => true ) , typemin (T)); Tmin = String (take! (io))
179+ show ( IOContext (io, :compact => true ) , typemax (T)); Tmax = String (take! (io))
181180 throw (ArgumentError (" $T is $bitstring type representing $n values from $Tmin to $Tmax ; cannot represent $x " ))
182181end
183182
0 commit comments