From f3af12100d566e349640569c80e9b84094d7183a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 1 Nov 2024 09:24:31 -0400 Subject: [PATCH 1/3] Add sinpi, cospi, tanpi, cis, cispi --- src/float8.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/float8.jl b/src/float8.jl index 7d1f1ff..23e7428 100644 --- a/src/float8.jl +++ b/src/float8.jl @@ -125,8 +125,10 @@ for op in (:+, :-, :*, :/, :\, :^) @eval ($op)(a::Float8_4, b::Float8_4) = Float8_4(($op)(Float32(a), Float32(b))) end -for func in (:sin,:cos,:tan,:asin,:acos,:atan,:sinh,:cosh,:tanh,:asinh,:acosh, - :atanh,:exp,:exp2,:exp10,:expm1,:log,:log2,:log10,:sqrt,:cbrt,:lgamma,:log1p) +for func in (:sin,:cos,:tan,:cis,:sinpi,:cospi,:tanpi,:cispi,:sinh,:cosh,:tanh, + :asin,:acos,:atan,,:asinh,:acosh,:atanh, + :exp,:exp2,:exp10,:expm1,:log,:log2,:log10,:log1p, + :sqrt,:cbrt,:lgamma) @eval begin $func(a::Float8) = Float8($func(Float32(a))) $func(a::Float8_4) = Float8_4($func(Float32(a))) From 3ac8a0dac8b584edbec0adf34a8079c3f7055928 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 1 Nov 2024 09:24:44 -0400 Subject: [PATCH 2/3] Re-enable disabled test --- test/runtests.jl | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 14c5f48..400938f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -69,21 +69,20 @@ end @testset "Conversion Float8 <-> Float32" begin @testset for i in 0x00:0xff - if ~isnan(Float8(i)) + if !isnan(Float8(i)) @test i == reinterpret(UInt8,Float8(Float32(Float8(i)))) end end end -# Currently not implemented -# @testset "Conversion Float8_4 <-> Float32" begin -# -# @testset for i in 0x00:0xff -# if ~isnan(Float8_4(i)) -# @test i == reinterpret(UInt8,Float8_4(Float32(Float8_4(i)))) -# end -# end -# end +@testset "Conversion Float8_4 <-> Float32" begin + + @testset for i in 0x00:0xff + if !isnan(Float8_4(i)) + @test i == reinterpret(UInt8,Float8_4(Float32(Float8_4(i)))) + end + end +end @testset "Negation" begin @@ -91,11 +90,11 @@ end f8 = Float8(i) f8_4 = Float8_4(i) - if ~isnan(f8) + if !isnan(f8) @test f8 == -(-f8) end - if ~isnan(f8_4) + if !isnan(f8_4) @test f8_4 == -(-f8_4) end end @@ -107,12 +106,12 @@ end f8 = Float8(i) f8_4 = Float8_4(i) - if ~isnan(f8) + if !isnan(f8) @test f8 >= floor(f8) @test f8 <= ceil(f8) end - if ~isnan(f8_4) + if !isnan(f8_4) @test f8_4 >= floor(f8_4) @test f8_4 <= ceil(f8_4) end @@ -127,7 +126,7 @@ end f1 = Float8(i) f2 = Float8(j) - if ~isnan(f1) && ~isnan(f2) && isfinite(f1) && isfinite(f2) + if !isnan(f1) && !isnan(f2) && isfinite(f1) && isfinite(f2) @test abs(f1) + abs(f2) >= abs(f1+f2) @test abs(f1) - abs(f2) <= abs(f1-f2) @test abs(f1) * abs(f2) >= f1*f2 @@ -144,7 +143,7 @@ end f1 = Float8_4(i) f2 = Float8_4(j) - if ~isnan(f1) && ~isnan(f2) && isfinite(f1) && isfinite(f2) + if !isnan(f1) && !isnan(f2) && isfinite(f1) && isfinite(f2) @test abs(f1) + abs(f2) >= abs(f1+f2) @test abs(f1) - abs(f2) <= abs(f1-f2) @test abs(f1) * abs(f2) >= f1*f2 From fc8238ccdb06dbbf8a27ab44337a18e0f582cb87 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 1 Nov 2024 09:26:26 -0400 Subject: [PATCH 3/3] Correct syntax error --- src/float8.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/float8.jl b/src/float8.jl index 23e7428..954b6cc 100644 --- a/src/float8.jl +++ b/src/float8.jl @@ -126,7 +126,7 @@ for op in (:+, :-, :*, :/, :\, :^) end for func in (:sin,:cos,:tan,:cis,:sinpi,:cospi,:tanpi,:cispi,:sinh,:cosh,:tanh, - :asin,:acos,:atan,,:asinh,:acosh,:atanh, + :asin,:acos,:atan,:asinh,:acosh,:atanh, :exp,:exp2,:exp10,:expm1,:log,:log2,:log10,:log1p, :sqrt,:cbrt,:lgamma) @eval begin