Skip to content

Commit 1a715d7

Browse files
authored
les: rework float conversion on arm64 and other architectures (#21994)
The previous fix #21960 converted the float to an intermediate signed int, before attempting the uint conversion. Although this works, this doesn't guarantee that other architectures will work the same.
1 parent fc0662b commit 1a715d7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎les/utils/expiredvalue.go‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ func (e *ExpiredValue) Add(amount int64, logOffset Fixed64) int64 {
8686
e.Exp = integer
8787
}
8888
if base >= 0 || uint64(-base) <= e.Base {
89-
// This is a temporary fix to circumvent a golang
90-
// uint conversion issue on arm64, which needs to
91-
// be investigated further. More details at:
89+
// The conversion from negative float64 to
90+
// uint64 is undefined in golang, and doesn't
91+
// work with ARMv8. More details at:
9292
// https://github.com/golang/go/issues/43047
93-
e.Base += uint64(int64(base))
93+
if base >= 0 {
94+
e.Base += uint64(base)
95+
} else {
96+
e.Base -= uint64(-base)
97+
}
9498
return amount
9599
}
96100
net := int64(-float64(e.Base) / factor)

0 commit comments

Comments
 (0)