Documentation
¶
Overview ¶
Package floats implements encoding and decoding of IEEE 754 floating-point values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Float128 ¶
type Float128 struct {
// contains filtered or unexported fields
}
Float128 represents a 128-bit IEEE 754 quadruple-precision floating-point value, in binary128 format.
References:
https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#IEEE_754_quadruple-precision_binary_floating-point_format:_binary128
type Float16 ¶
type Float16 struct {
// contains filtered or unexported fields
}
Float16 represents a 16-bit IEEE 754 half-precision floating-point value, in binary16 format.
References:
https://en.wikipedia.org/wiki/Half-precision_floating-point_format#IEEE_754_half-precision_binary_floating-point_format:_binary16
func NewFloat16FromBits ¶
NewFloat16FromBits returns a new 16-bit floating-point value based on bits.
func NewFloat16FromBytes ¶
NewFloat16FromBytes returns a new 16-bit floating-point value based on b, which contains 4 bytes in hexadecimal format.
func NewFloat16FromFloat32 ¶
NewFloat16FromFloat32 returns the nearest 16-bit floating-point value for x and a bool indicating whether f represents x exactly.
func NewFloat16FromFloat64 ¶
NewFloat16FromFloat64 returns the nearest 16-bit floating-point value for x and a bool indicating whether f represents x exactly.
func NewFloat16FromString ¶
NewFloat16FromString returns a new 16-bit floating-point value based on s, which contains 4 bytes in hexadecimal format.
func (Float16) Bytes ¶
Bytes returns the IEEE 754 binary representation of f as a byte slice, containing 4 bytes in hexadecimal format.
type Float80 ¶
type Float80 struct {
// contains filtered or unexported fields
}
Float80 represents an 80-bit IEEE 754 extended precision floating-point value, in x86 extended precision format.
References:
https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format
func NewFloat80FromBits ¶
NewFloat80FromBits returns a new 80-bit floating-point value based on the sign, exponent and mantissa bits.
func NewFloat80FromBytes ¶
NewFloat80FromBytes returns a new 80-bit floating-point value based on b, which contains 20 bytes in hexadecimal format.
func NewFloat80FromFloat64 ¶
NewFloat80FromFloat64 returns the nearest 80-bit floating-point value for x.
func NewFloat80FromString ¶
NewFloat80FromString returns a new 80-bit floating-point value based on s, which contains 20 bytes in hexadecimal format.
func (Float80) Bits ¶
Bits returns the IEEE 754 binary representation of f, with the sign and exponent in se and the mantissa in m.
func (Float80) Bytes ¶
Bytes returns the x86 extended precision binary representation of f as a byte slice.