Skip to content

Commit 3e666ec

Browse files
committed
Merge pull request #16 from JuliaLang/jrg/UInt
Fix warnings on julia 0.4
2 parents 95eabfd + c557df7 commit 3e666ec

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/SortingAlgorithms.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ end
4242

4343
# Map a bits-type to an unsigned int, maintaining sort order
4444
uint_mapping(::ForwardOrdering, x::Unsigned) = x
45-
for (signedty, unsignedty) in ((Int8, Uint8), (Int16, Uint16), (Int32, Uint32), (Int64, Uint64), (Int128, Uint128))
45+
for (signedty, unsignedty) in ((Int8, UInt8), (Int16, UInt16), (Int32, UInt32), (Int64, UInt64), (Int128, UInt128))
4646
# In Julia 0.4 we can just use unsigned() here
4747
@eval uint_mapping(::ForwardOrdering, x::$signedty) = reinterpret($unsignedty, x $ typemin(typeof(x)))
4848
end
49-
uint_mapping(::ForwardOrdering, x::Float32) = (y = reinterpret(Int32, x); reinterpret(Uint32, ifelse(y < 0, ~y, y $ typemin(Int32))))
50-
uint_mapping(::ForwardOrdering, x::Float64) = (y = reinterpret(Int64, x); reinterpret(Uint64, ifelse(y < 0, ~y, y $ typemin(Int64))))
49+
uint_mapping(::ForwardOrdering, x::Float32) = (y = reinterpret(Int32, x); reinterpret(UInt32, ifelse(y < 0, ~y, y $ typemin(Int32))))
50+
uint_mapping(::ForwardOrdering, x::Float64) = (y = reinterpret(Int64, x); reinterpret(UInt64, ifelse(y < 0, ~y, y $ typemin(Int64))))
5151

5252
uint_mapping{Fwd}(rev::ReverseOrdering{Fwd}, x) = ~uint_mapping(rev.fwd, x)
5353
uint_mapping{T<:Real}(::ReverseOrdering{ForwardOrdering}, x::T) = ~uint_mapping(Forward, x) # maybe unnecessary; needs benchmark
@@ -71,7 +71,7 @@ function sort!(vs::AbstractVector, lo::Int, hi::Int, ::RadixSortAlg, o::Ordering
7171

7272
# Init
7373
iters = ceil(Integer, sizeof(T)*8/RADIX_SIZE)
74-
bin = zeros(Uint32, 2^RADIX_SIZE, iters)
74+
bin = zeros(UInt32, 2^RADIX_SIZE, iters)
7575
if lo > 1; bin[1,:] = lo-1; end
7676

7777
# Histogram for each element, radix

test/runtests.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Base.Test
22
using SortingAlgorithms
3+
using Compat
34

45
a = rand(1:10000, 1000)
56

@@ -41,7 +42,7 @@ for alg in [TimSort, HeapSort, RadixSort]
4142
@test b == c
4243
end
4344

44-
randnans(n) = reinterpret(Float64,[rand(Uint64)|0x7ff8000000000000 for i=1:n])
45+
randnans(n) = reinterpret(Float64,[rand(UInt64)|0x7ff8000000000000 for i=1:n])
4546

4647
function randn_with_nans(n,p)
4748
v = randn(n)
@@ -101,13 +102,13 @@ for n in [0:10..., 100, 101, 1000, 1001]
101102
# test float sorting with NaNs
102103
s = sort(v, alg=alg, order=ord)
103104
@test issorted(s, order=ord)
104-
@test reinterpret(Uint64,v[isnan(v)]) == reinterpret(Uint64,s[isnan(s)])
105+
@test reinterpret(UInt64,v[isnan(v)]) == reinterpret(UInt64,s[isnan(s)])
105106

106107
# test float permutation with NaNs
107108
p = sortperm(v, alg=alg, order=ord)
108109
@test isperm(p)
109110
vp = v[p]
110111
@test isequal(vp,s)
111-
@test reinterpret(Uint64,vp) == reinterpret(Uint64,s)
112+
@test reinterpret(UInt64,vp) == reinterpret(UInt64,s)
112113
end
113114
end

0 commit comments

Comments
 (0)