Skip to content

Commit 6e24f5d

Browse files
committed
more correct CloseClose
1 parent 79158c3 commit 6e24f5d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/sampling.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ rand(r::AbstractRNG, sp::SamplerSimple{OpenOpen01{T}}) where {T} =
5252
x != zero(T) && return x
5353
end
5454

55+
# prevfloat(T(2)) - 1 for IEEEFloat
56+
upper01(::Type{Float64}) = 0.9999999999999998
57+
upper01(::Type{Float32}) = 0.9999999f0
58+
upper01(::Type{Float16}) = Float16(0.999)
59+
upper01(::Type{BigFloat}) = prevfloat(one(BigFloat))
60+
5561
rand(r::AbstractRNG, sp::SamplerSimple{CloseClose01{T}}) where {T} =
56-
rand(r, sp.data) / prevfloat(one(T))
62+
rand(r, sp.data) / upper01(T)
5763

5864
### CloseOpenAB
5965

0 commit comments

Comments
 (0)