Float classification and bits v0.1.0
IsNan
pub func IsNan(value: float16) -> bool
pub func IsNan(value: float32) -> bool
pub func IsNan(value: float64) -> bool
pub func IsNan(value: float8) -> bool
Provides the public IsNan operation.
Parameters
| Name | Type | Description |
|---|---|---|
value | float16 / float32 / float64 / float8 | the value to act on |
Returns: whether the value is a NaN
IsInfinite
pub func IsInfinite(value: float16) -> bool
pub func IsInfinite(value: float32) -> bool
pub func IsInfinite(value: float64) -> bool
pub func IsInfinite(value: float8) -> bool
Provides the public IsInfinite operation.
Parameters
| Name | Type | Description |
|---|---|---|
value | float16 / float32 / float64 / float8 | the value to act on |
Returns: whether the value is either infinity
IsFinite
pub func IsFinite(value: float16) -> bool
pub func IsFinite(value: float32) -> bool
pub func IsFinite(value: float64) -> bool
pub func IsFinite(value: float8) -> bool
Provides the public IsFinite operation.
Parameters
| Name | Type | Description |
|---|---|---|
value | float16 / float32 / float64 / float8 | the value to act on |
Returns: whether the value is neither infinite nor a NaN
BitsOfFloat64
pub func BitsOfFloat64(value: float64) -> uint64
The bits of value, as they are stored.
Reads the value's storage as an integer of the same width through a raw pointer. This is the representation
rather than the value: there is no conversion that preserves the bits, since a cast asks for the number.
Parameters
| Name | Type | Description |
|---|---|---|
value | float64 | the float to read |
Returns: its sixty-four bits
BitsOfFloat32
pub func BitsOfFloat32(value: float32) -> uint32
The bits of value, as they are stored.
As BitsOfFloat64, at the narrower width.
Parameters
| Name | Type | Description |
|---|---|---|
value | float32 | the float to read |
Returns: its thirty-two bits
BitsOfFloat16
pub func BitsOfFloat16(value: float16) -> uint16
The bits of value, as they are stored.
As BitsOfFloat64, at the half-precision width.
Parameters
| Name | Type | Description |
|---|---|---|
value | float16 | the float to read |
Returns: its sixteen bits
BitsOfFloat8
pub func BitsOfFloat8(value: float8) -> uint8
The bits of value, as they are stored.
As BitsOfFloat64, at the eight-bit width: a sign, four exponent bits and three stored significand bits.
Parameters
| Name | Type | Description |
|---|---|---|
value | float8 | the float to read |
Returns: its eight bits
Float64FromBits
pub func Float64FromBits(bits: uint64) -> float64
The float64 whose bits are bits.
Writes the value's storage from an integer of the same width through a raw pointer, which is the inverse of
BitsOfFloat64 and unsafe for the same reason: there is no conversion that preserves a representation.
Parameters
| Name | Type | Description |
|---|---|---|
bits | uint64 | the sixty-four bits to read as a value |
Returns: the value they spell
Float32FromBits
pub func Float32FromBits(bits: uint32) -> float32
The float32 whose bits are bits.
As Float64FromBits, at the narrower width.
Parameters
| Name | Type | Description |
|---|---|---|
bits | uint32 | the thirty-two bits to read as a value |
Returns: the value they spell