Skip to content

Commit

Permalink
Fix depwarns on 0.6, remove a few defs for 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Feb 8, 2017
1 parent 14b1f33 commit 01b7802
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
16 changes: 7 additions & 9 deletions src/FixedPointNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ import Base: ==, <, <=, -, +, *, /, ~, isapprox,
isnan, isinf, isfinite,
zero, one, typemin, typemax, realmin, realmax, eps, sizeof, reinterpret,
float, trunc, round, floor, ceil, bswap,
div, fld, rem, mod, mod1, rem1, fld1, min, max, minmax,
div, fld, rem, mod, mod1, fld1, min, max, minmax,
start, next, done, r_promote, reducedim_init, rand

if VERSION <= v"0.5.0-dev+755"
macro pure(ex)
nothing
end
else
using Base: @pure
if isdefined(Base, :rem1)
import Base: rem1
end
using Base: @pure

using Compat
import Compat.String

# T => BaseType
# f => Number of Bytes reserved for fractional part
Expand Down Expand Up @@ -141,6 +136,9 @@ for f in (:div, :fld, :fld1)
end
end
for f in (:rem, :mod, :mod1, :rem1, :min, :max)
if f === :rem1 && !isdefined(Base, :rem1)
continue
end
@eval begin
$f{T<:FixedPoint}(x::T, y::T) = T($f(reinterpret(x),reinterpret(y)),0)
end
Expand Down
5 changes: 2 additions & 3 deletions src/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ immutable Fixed{T <: Signed,f} <: FixedPoint{T, f}

# constructor for manipulating the representation;
# selected by passing an extra dummy argument
Fixed(i::Integer,_) = new(i % T)

Fixed(x) = convert(Fixed{T,f}, x)
(::Type{Fixed{T, f}}){T, f}(i::Integer, _) = new{T, f}(i % T)
(::Type{Fixed{T, f}}){T, f}(x) = convert(Fixed{T,f}, x)
end

reinterpret{T<:Signed, f}(::Type{Fixed{T,f}}, x::T) = Fixed{T,f}(x, 0)
Expand Down
4 changes: 2 additions & 2 deletions src/normed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
immutable Normed{T<:Unsigned,f} <: FixedPoint{T,f}
i::T

Normed(i::Integer,_) = new(i%T) # for setting by raw representation
Normed(x) = convert(Normed{T,f}, x)
(::Type{Normed{T, f}}){T, f}(i::Integer,_) = new{T, f}(i%T) # for setting by raw representation
(::Type{Normed{T, f}}){T, f}(x) = convert(Normed{T,f}, x)
end

rawtype{T,f}(::Type{Normed{T,f}}) = T
Expand Down

0 comments on commit 01b7802

Please sign in to comment.