You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the following program on a Mac M1 (darwin/arm64):
package main
import (
"fmt"
"math"
)
func main() {
v := Vec3{20, 80, 15}
x1 := Vec3{-0.037400786, 0, 0.06233464}.Norm().Dot(v)
x2 := f(v)
fmt.Println(x1)
fmt.Println(x2)
}
func f(v Vec3) float32 {
// same calculation as for x1 above, but different result
return Vec3{-0.037400786, 0, 0.06233464}.Norm().Dot(v)
}
type Vec3 struct {
X, Y, Z float32
}
// Norm returns the normalized vector of v.
func (v Vec3) Norm() Vec3 {
l := float32(math.Sqrt(float64(v.Dot(v))))
return Vec3{v.X / l, v.Y / l, v.Z / l}
}
// Dot returns the dot product of v and w.
func (v Vec3) Dot(w Vec3) float32 {
return v.X*w.X + v.Y*w.Y + v.Z*w.Z
}
What did you expect to see?
These are the expected results I see on an Intel Mac machine:
2.5724783
2.5724783
Same results, due to same calculation for x1 and x2.
What did you see instead?
These are the deviating results I see on an M1 Mac machine:
2.5724783
2.5724788
The text was updated successfully, but these errors were encountered:
An implementation may combine multiple floating-point operations into a single fused operation, possibly across statements, and produce a result that differs from the value obtained by executing and rounding the instructions individually
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run the following program on a Mac M1 (darwin/arm64):
What did you expect to see?
These are the expected results I see on an Intel Mac machine:
Same results, due to same calculation for x1 and x2.
What did you see instead?
These are the deviating results I see on an M1 Mac machine:
The text was updated successfully, but these errors were encountered: