Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/bfloat16.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ if llvm_arithmetic
end
end
else
BFloat16(x::Integer) = convert(BFloat16, convert(Float32, x))
BFloat16(x::Integer) = convert(BFloat16, convert(Float32, x)::Float32)
end
# TODO: optimize
BFloat16(x::UInt128) = convert(BFloat16, Float64(x))
Expand Down Expand Up @@ -424,3 +424,6 @@ for F in (:abs, :abs2, :sqrt, :cbrt,
Base.$F(x::BFloat16) = BFloat16($F(Float32(x)))
end
end

# irrationals
BFloat16(x::AbstractIrrational) = BFloat16(Float32(x)::Float32)
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ end
@test Int64(BFloat16(10)) == Int64(10)
@test BFloat16(BigFloat(1)) == BFloat16(1)
@test BigFloat(BFloat16(1)) == BigFloat(1)
@test BFloat16(pi) == BFloat16(3.14159)
@test all(R -> R<:BFloat16, Base.return_types(BFloat16))
end

@testset "abi" begin
Expand Down Expand Up @@ -189,4 +191,4 @@ end
end

include("structure.jl")
include("mathfuncs.jl")
include("mathfuncs.jl")
Loading