Unverified Commit 1a715d7d authored by Guillaume Ballet's avatar Guillaume Ballet Committed by GitHub

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.
parent fc0662bb
...@@ -86,11 +86,15 @@ func (e *ExpiredValue) Add(amount int64, logOffset Fixed64) int64 { ...@@ -86,11 +86,15 @@ func (e *ExpiredValue) Add(amount int64, logOffset Fixed64) int64 {
e.Exp = integer e.Exp = integer
} }
if base >= 0 || uint64(-base) <= e.Base { if base >= 0 || uint64(-base) <= e.Base {
// This is a temporary fix to circumvent a golang // The conversion from negative float64 to
// uint conversion issue on arm64, which needs to // uint64 is undefined in golang, and doesn't
// be investigated further. More details at: // work with ARMv8. More details at:
// https://github.com/golang/go/issues/43047 // https://github.com/golang/go/issues/43047
e.Base += uint64(int64(base)) if base >= 0 {
e.Base += uint64(base)
} else {
e.Base -= uint64(-base)
}
return amount return amount
} }
net := int64(-float64(e.Base) / factor) net := int64(-float64(e.Base) / factor)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment