Description
Currently, functions that rely on properties of a floating-point number like its sign-bit, nan-checking, and integer representation get duplicated across packages. For instance,
For instance, isFinite
, isInf
, abs
, copysign
, float64bits
, and float64frombits
are defined in both math
and runtime
.
isNaN
itself is defined in math
, math/bits
, runtime
, sort
.
I propose that we move the declarations in runtime/float.go
to internal/float
and reuse them in both math
, runtime
, and anyplace else.
I assume this hasn't been done already because internal packages didn't exist at the time most of this code was written. In the case of sort
, we wanted to remove its dependency on math
, but if we end up adopting #33440, sort
will need more access to a float64's underlying representation.