Skip to content

Commit 652411a

Browse files
Fix deprecations
1 parent 8bfa7c2 commit 652411a

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

src/FixedPointNumbers.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,14 @@ function show(io::IO, x::FixedPoint{T,f}) where {T,f}
105105
showtype(io, typeof(x))
106106
end
107107
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-
110-
if VERSION >= v"0.7.0-DEV.1790"
111-
function Base.showarg(io::IO, a::Array{T}, toplevel) where {T<:FixedPoint}
112-
toplevel || print(io, "::")
113-
print(io, "Array{")
114-
showtype(io, T)
115-
print(io, ",$(ndims(a))}")
116-
toplevel && print(io, " with eltype ", T)
117-
end
108+
showcompact(io::IO, x::FixedPoint{T,f}) where {T,f} = show(io, round(convert(Float64,x), digits=ceil(Int, digits=f/_log2_10)))
109+
110+
function Base.showarg(io::IO, a::Array{T}, toplevel) where {T<:FixedPoint}
111+
toplevel || print(io, "::")
112+
print(io, "Array{")
113+
showtype(io, T)
114+
print(io, ",$(ndims(a))}")
115+
toplevel && print(io, " with eltype ", T)
118116
end
119117

120118
include("fixed.jl")

src/fixed.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ end
1010
Fixed{T, f}(x::AbstractChar) where {T,f} = throw(ArgumentError("Fixed cannot be constructed from a Char"))
1111
Fixed{T, f}(x::Complex) where {T,f} = Fixed{T, f}(convert(real(typeof(x)), x))
1212
Fixed{T, f}(x::Base.TwicePrecision) where {T,f} = Fixed{T, f}(convert(Float64, x))
13-
Fixed{T,f}(x::Integer) where {T,f} = Fixed{T,f}(round(T, convert(widen1(T),x)<<f),0)
14-
Fixed{T,f}(x::AbstractFloat) where {T,f} = Fixed{T,f}(round(T, trunc(widen1(T),x)<<f + rem(x,1)*(one(widen1(T))<<f)),0)
13+
Fixed{T,f}(x::Integer) where {T,f} = Fixed{T,f}(round(T, digits=convert(widen1(T),x)<<f),0)
14+
Fixed{T,f}(x::AbstractFloat) where {T,f} = Fixed{T,f}(round(T, digits=trunc(widen1(T), digits=x)<<f + rem(x,1)*(one(widen1(T))<<f)),0)
1515
Fixed{T,f}(x::Rational) where {T,f} = Fixed{T,f}(x.num)/Fixed{T,f}(x.den)
1616

1717
reinterpret(::Type{Fixed{T,f}}, x::T) where {T <: Signed,f} = Fixed{T,f}(x, 0)

src/normed.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ function ceil(x::Normed{T,f}) where {T,f}
114114
Normed{T,f}(y+oneunit(Normed{T,f})) : y
115115
end
116116

117-
trunc(::Type{T}, x::Normed) where {T <: Integer} = convert(T, div(reinterpret(x), rawone(x)))
118-
round(::Type{T}, x::Normed) where {T <: Integer} = round(T, reinterpret(x)/rawone(x))
119-
floor(::Type{T}, x::Normed) where {T <: Integer} = trunc(T, x)
120-
ceil(::Type{T}, x::Normed) where {T <: Integer} = ceil(T, reinterpret(x)/rawone(x))
117+
trunc(::Type{T}, digits=x::Normed) where {T <: Integer} = convert(T, div(reinterpret(x), rawone(x)))
118+
round(::Type{T}, digits=x::Normed) where {T <: Integer} = round(T, digits=reinterpret(x)/rawone(x))
119+
floor(::Type{T}, digits=x::Normed) where {T <: Integer} = trunc(T, digits=x)
120+
ceil(::Type{T}, digits=x::Normed) where {T <: Integer} = ceil(T, digits=reinterpret(x)/rawone(x))
121121

122122
isfinite(x::Normed) = true
123123
isnan(x::Normed) = false

test/normed.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ function testtrunc(inc::T) where {T}
176176
end
177177
@test typeof(floor(x)) == T
178178
@test floor(x) == floor(xf)
179-
@test trunc(Int,x) == trunc(Int,xf)
180-
@test round(Int,x) == round(Int,xf)
181-
@test floor(Int,x) == floor(Int,xf)
179+
@test trunc(Int, digits=x) == trunc(Int, digits=xf)
180+
@test round(Int, digits=x) == round(Int, digits=xf)
181+
@test floor(Int, digits=x) == floor(Int, digits=xf)
182182
if cxf < tm
183-
@test ceil(Int,x) == ceil(Int,xf)
183+
@test ceil(Int, digits=x) == ceil(Int, digits=xf)
184184
end
185185
catch err
186186
println("Failed on x = ", x, ", xf = ", xf)

0 commit comments

Comments
 (0)