Documentation ¶
Index ¶
- func Abs[T Signed | Float](x T) T
- func Convert[Tr Number, Ts Number](src Ts) Tr
- func FromBool[T Number](v bool) T
- func SetFromBool[T Number](dst *T, b bool)
- func SetNumber[Td Number, Ts Number](dst *Td, src Ts)
- func ToBool[T Number](v T) bool
- type Complex
- type Float
- type Integer
- type Number
- type Ordered
- type Signed
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert converts any number to any other, using generics, with the return number specified by the first type argument, and the source number by the second. Typically the source type can be inferred but the return cannot. See SetNumber for a version that uses a pointer to the destination which avoids the need to specify the type parameter.
func FromBool ¶
FromBool returns a 1 if the bool is true and a 0 for false. Typically the type parameter cannot be inferred and must be provided. See SetFromBool for a version that uses a pointer to the destination which avoids the need to specify the type parameter.
func SetFromBool ¶
SetFromBool converts a bool into a number, using generics, setting the pointer to the dst destination value to a 1 if bool is true, and 0 otherwise. This version of FromBool does not require type parameters typically.
Types ¶
type Complex ¶
type Complex interface { ~complex64 | ~complex128 }
Complex is a constraint that permits any complex numeric type. If future releases of Go add new predeclared complex numeric types, this constraint will be modified to include them.
type Float ¶
Float is a constraint that permits any floating-point type. If future releases of Go add new predeclared floating-point types, this constraint will be modified to include them.
type Integer ¶
Integer is a constraint that permits any integer type. If future releases of Go add new predeclared integer types, this constraint will be modified to include them.
type Number ¶
Number is a constraint that permits any single-valued numerical type, i.e., Integer or Float. It excludes complex numbers.
type Ordered ¶
Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >. If future releases of Go add new ordered types, this constraint will be modified to include them.