Skip to content

Commit 72d937e

Browse files
authored
Merge pull request #75 from JuliaMath/teh/more_ambs
Work around another ambiguity and centralize floattype, nbitsfrac, an…
2 parents 872675d + 486edf4 commit 72d937e

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/FixedPointNumbers.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,16 @@ widen1(x::Integer) = x % widen1(typeof(x))
8585
typealias ShortInts Union{Int8,UInt8,Int16,UInt16}
8686

8787
floattype{T<:ShortInts,f}(::Type{FixedPoint{T,f}}) = Float32
88-
floattype{T,f}(::Type{FixedPoint{T,f}}) = Float64
89-
floattype(x::FixedPoint) = floattype(supertype(typeof(x)))
88+
floattype{T<:Integer,f}(::Type{FixedPoint{T,f}}) = Float64
89+
floattype{F<:FixedPoint}(::Type{F}) = floattype(supertype(F))
90+
floattype(x::FixedPoint) = floattype(typeof(x))
91+
92+
nbitsfrac{T<:Integer,f}(::Type{FixedPoint{T,f}}) = f
93+
nbitsfrac{F<:FixedPoint}(::Type{F}) = nbitsfrac(supertype(F))
94+
95+
rawtype{T<:Integer,f}(::Type{FixedPoint{T,f}}) = T
96+
rawtype{F<:FixedPoint}(::Type{F}) = rawtype(supertype(F))
97+
rawtype(x::FixedPoint) = rawtype(typeof(x))
9098

9199
# This IOBuffer is used during module definition to generate typealias names
92100
_iotypealias = IOBuffer()

src/fixed.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ end
1010

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

13-
rawtype{T,f}(::Type{Fixed{T,f}}) = T
14-
nbitsfrac{T,f}(::Type{Fixed{T,f}}) = f
15-
floattype{T<:Fixed}(::Type{T}) = floattype(supertype(T))
1613
typechar{X<:Fixed}(::Type{X}) = 'Q'
1714
signbits{X<:Fixed}(::Type{X}) = 1
1815

src/normed.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ immutable Normed{T<:Unsigned,f} <: FixedPoint{T,f}
88
(::Type{Normed{T, f}}){T, f}(x) = convert(Normed{T,f}, x)
99
end
1010

11-
rawtype{T,f}(::Type{Normed{T,f}}) = T
12-
rawtype(x::Number) = rawtype(typeof(x))
13-
nbitsfrac{T,f}(::Type{Normed{T,f}}) = f
14-
floattype{T<:Normed}(::Type{T}) = floattype(supertype(T))
1511
typechar{X<:Normed}(::Type{X}) = 'N'
1612
signbits{X<:Normed}(::Type{X}) = 0
1713

0 commit comments

Comments
 (0)