]> Cypherpunks.ru repositories - gostls13.git/commit
math: add Compare and Compare32
authorAkhil Indurti <aindurti@gmail.com>
Sat, 11 Feb 2023 03:08:14 +0000 (19:08 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 15 Feb 2023 21:56:30 +0000 (21:56 +0000)
commit3348fd0ec9be0189f88e991db1d94f437ec04bd1
tree2e44bb03dff98911d45542bb95e933a93d1f0d1a
parent40ed3591829f67e7a116180aec543dd15bfcf5f9
math: add Compare and Compare32

This change introduces the Compare and Compare32 functions
based on the total-ordering predicate in IEEE-754, section 5.10.

In particular,
* -NaN is ordered before any other value
* +NaN is ordered after any other value
* -0 is ordered before +0
* All other values are ordered the usual way

Compare-8    0.4537n ± 1%
Compare32-8  0.3752n ± 1%
geomean      0.4126n

Fixes #56491.

Change-Id: I5c9c77430a2872f380688c1b0a66f2105b77d5ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/467515
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
api/next/56491.txt [new file with mode: 0644]
src/math/all_test.go
src/math/compare.go [new file with mode: 0644]