Skip to content

Commit f062f10

Browse files
committed
fix typo in Float32 number generation
introduced in #56144
1 parent c269329 commit f062f10

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

stdlib/Random/src/XoshiroSimd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ simdThreshold(::Type{Bool}) = 640
4646
ui = (x>>>32) % UInt32
4747
li = x % UInt32
4848
u = _uint2float(ui, Float32)
49-
l = _uint2float(ui, Float32)
49+
l = _uint2float(li, Float32)
5050
(UInt64(reinterpret(UInt32, u)) << 32) | UInt64(reinterpret(UInt32, l))
5151
end
5252
@inline function _bits2float(x::UInt64, ::Type{Float16})

stdlib/Random/test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,12 @@ end
12501250
@test length(xs) == 3
12511251
end
12521252

1253+
@testset "float32 bug" begin
1254+
a = rand(Float32, 4)
1255+
@test a[1] != a[2]
1256+
@test a[3] != a[4]
1257+
end
1258+
12531259
@testset "Docstrings" begin
12541260
@test isempty(Docs.undocumented_names(Random))
12551261
end

0 commit comments

Comments
 (0)