x/website: SumNumbers depends on map iteration order with float64 #51715
Labels
Documentation
Issues describing a change to documentation.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
website
Milestone
What version of Go are you using (
go version
)?Go 1.18 via playground.
What did you do?
I added extreme float64 values to the input of the
SumNumbers
function from https://go.dev/doc/tutorial/generics.https://go.dev/play/p/aQ1cotOVsEc
What did you expect to see?
The function returns the same value consistently.
What did you see instead?
Across 4 runs:
Re-running this may provide different results.
The function works correctly with
int64
because integer addition is associative. Addition is not associative withfloat64
values, so the map order changes the result dramatically.The text was updated successfully, but these errors were encountered: