Skip to content

Commit 0b4717f

Browse files
committed
fix(bindings): Go and C++ one() constant uses from_f32(1.0)
GF16_ONE=0x3C00 decodes to 0.25, not 1.0. Use from_f32(1.0) roundtrip instead.
1 parent 1d88377 commit 0b4717f

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

cpp/include/goldenfloat/gf16.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class Gf16 {
100100
/**
101101
* @brief One constant
102102
*/
103-
static constexpr Gf16 one() noexcept {
104-
return Gf16(GF16_ONE);
103+
static Gf16 one() noexcept {
104+
return from_f32(1.0f);
105105
}
106106

107107
/**

go/goldenfloat/gf16.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ func (a Gf16) Fma(b, c Gf16) Gf16 {
107107
return Gf16(C.gf16_fma(C.uint16_t(a), C.uint16_t(b), C.uint16_t(c)))
108108
}
109109

110+
var One = FromF32(1.0)
111+
110112
const (
111113
Zero Gf16 = 0x0000
112-
One Gf16 = 0x3C00
113114
PInf Gf16 = 0x7E00
114115
NInf Gf16 = 0xFE00
115116
NaN Gf16 = 0x7E01

0 commit comments

Comments
 (0)