Skip to content

Commit 514563e

Browse files
committed
feat!: implement tentative arithmetic operators for bfloat16
Signed-off-by: Krishna Pandey <[email protected]>
1 parent de7b4ea commit 514563e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libc/src/__support/FPUtil/bfloat16.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ struct BFloat16 {
6464
return result.get_val();
6565
}
6666

67+
// TODO: this need to be changed!
68+
LIBC_INLINE constexpr BFloat16 operator+(BFloat16 x) {
69+
float a = static_cast<float>(*this);
70+
float b = static_cast<float>(x);
71+
return BFloat16(a + b);
72+
}
73+
74+
// TODO: this need to be changed!
75+
LIBC_INLINE constexpr BFloat16 operator-(BFloat16 x) {
76+
float a = static_cast<float>(*this);
77+
float b = static_cast<float>(x);
78+
return BFloat16(a - b);
79+
}
80+
6781
}; // struct BFloat16
6882

6983
} // namespace fputil

0 commit comments

Comments
 (0)