Skip to content

Commit 829251b

Browse files
authored
Merge pull request #93 from christiangnrd/redundant
Remove redundant operator definitions
2 parents bcbed56 + 0f527db commit 829251b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bfloat16.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Base: isfinite, isnan, precision, iszero, eps,
55
exponent_one, exponent_half, leading_zeros,
66
signbit, exponent, significand, frexp, ldexp,
77
round, Int16, Int32, Int64,
8-
+, -, *, /, ^, ==, <, <=, >=, >, !=, inv,
8+
+, -, *, /, ^, ==, <, <=, inv,
99
abs, abs2, uabs, sqrt, cbrt,
1010
exp, exp2, exp10, expm1,
1111
log, log2, log10, log1p,
@@ -269,8 +269,9 @@ function ==(x::BFloat16, y::BFloat16)
269269
return ix == iy
270270
end
271271

272-
for op in (:<, :<=, :>, :>=, :!=)
273-
@eval ($op)(a::BFloat16, b::BFloat16) = ($op)(Float32(a), Float32(b))
272+
<(a::BFloat16, b::BFloat16) = Float32(a) < Float32(b)
273+
@static if VERSION < v"1.8"
274+
<=(a::BFloat16, b::BFloat16) = Float32(a) <= Float32(b)
274275
end
275276

276277
Base.widen(::Type{BFloat16}) = Float32

0 commit comments

Comments
 (0)