Skip to content

Commit e4b95a9

Browse files
authored
add Float16 conversions (#28)
1 parent 5720401 commit e4b95a9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Quadmath.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ Float128(x::Float32) =
136136
Float32(x::Float128) =
137137
@ccall(quadoplib.__trunctfsf2(x::Cfloat128)::Cfloat)
138138

139+
# Float16
140+
Float128(x::Float16) = Float128(Float32(x))
141+
Float16(x::Float128) = Float16(Float32(x)) # TODO: avoid double rounding
142+
139143
# integer -> Float128
140144
Float128(x::Int32) =
141145
Float128(@ccall(quadoplib.__floatsitf(x::Int32)::Cfloat128))

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using Quadmath
1111
end
1212

1313
@testset "conversions" begin
14-
@testset "conversion $T" for T in (Float32, Float64, Int32, Int64, Int128, UInt32, UInt64, UInt128, BigFloat, BigInt)
14+
@testset "conversion $T" for T in (Float16, Float32, Float64, Int32, Int64, Int128, UInt32, UInt64, UInt128, BigFloat, BigInt)
1515
@test Float128(T(1)) + Float128(T(2)) == Float128(T(3))
1616
@test Float128(T(1)) + Float128(T(2)) <= Float128(T(3))
1717
@test Float128(T(1)) + Float128(T(2)) != Float128(T(4))

0 commit comments

Comments
 (0)