@@ -5,7 +5,7 @@ module FixedPointNumbers
5
5
using Base: reducedim_initarray
6
6
7
7
import Base: == , < , <= , - , + , * , / , ~ , isapprox,
8
- convert, promote_rule, show, showcompact, isinteger, abs, decompose,
8
+ convert, promote_rule, show, isinteger, abs, decompose,
9
9
isnan, isinf, isfinite,
10
10
zero, oneunit, one, typemin, typemax, realmin, realmax, eps, sizeof, reinterpret,
11
11
float, trunc, round, floor, ceil, bswap,
@@ -101,11 +101,10 @@ function showtype(io::IO, ::Type{X}) where {X <: FixedPoint}
101
101
io
102
102
end
103
103
function 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))
106
106
end
107
107
const _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)))
109
108
110
109
function Base. showarg (io:: IO , a:: Array{T} , toplevel) where {T<: FixedPoint }
111
110
toplevel || print (io, " ::" )
@@ -176,8 +175,8 @@ scaledual(b::Tdual, x::Union{T,AbstractArray{T}}) where {Tdual <: Number,T <: Fi
176
175
n = 2 ^ (8 * sizeof (T))
177
176
bitstring = sizeof (T) == 1 ? " an 8-bit" : " a $(8 * sizeof (T)) -bit"
178
177
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))
181
180
throw (ArgumentError (" $T is $bitstring type representing $n values from $Tmin to $Tmax ; cannot represent $x " ))
182
181
end
183
182
0 commit comments