diff --git a/src/misc.jl b/src/misc.jl index aac3abf..1a34e08 100644 --- a/src/misc.jl +++ b/src/misc.jl @@ -66,7 +66,7 @@ lstirling_asym(x::BigFloat) = loggamma(x) + x - log(x)*(x - big(0.5)) - log2π/b lstirling_asym(x::Integer) = lstirling_asym(float(x)) const lstirlingF64 = Float64[lstirling_asym(k) for k in big(1):big(64)] -const lstirlingF32 = Float64[lstirling_asym(k) for k in big(1):big(40)] +const lstirlingF32 = [Float32(lstirlingF64[i]) for i in 1:40] function lstirling_asym(x::Float64) isinteger(x) && (0 < x ≤ length(lstirlingF64)) && return lstirlingF64[Int(x)] diff --git a/test/misc.jl b/test/misc.jl index 1d5d7f0..d57a94c 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -70,3 +70,10 @@ end @test isone(binompdf(n, p, k)) end end + +@testset "lstirling_asym" begin + # can test for equality here because the lhs is the way the value is created + @test Float32(lstirling_asym(1.0)) == @inferred lstirling_asym(1.0f0) + # for 64.0f0 the expansion is used but for 64.0 the BigFloat value is rounded + @test Float32(lstirling_asym(64.0)) ≈ @inferred lstirling_asym(64.0f0) +end