floats

package
v0.0.0-...-c756be7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2018 License: Unlicense Imports: 4 Imported by: 0

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

func (Float128) Bytes

func (f Float128) Bytes() []byte

Bytes returns the IEEE 754 binary representation of f as a byte slice.

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

func NewFloat16FromBits(bits uint16) Float16

NewFloat16FromBits returns a new 16-bit floating-point value based on bits.

func NewFloat16FromBytes

func NewFloat16FromBytes(b []byte) Float16

NewFloat16FromBytes returns a new 16-bit floating-point value based on b, which contains 4 bytes in hexadecimal format.

func NewFloat16FromFloat32

func NewFloat16FromFloat32(x float32) (f Float16, exact bool)

NewFloat16FromFloat32 returns the nearest 16-bit floating-point value for x and a bool indicating whether f represents x exactly.

func NewFloat16FromFloat64

func NewFloat16FromFloat64(x float64) (f Float16, exact bool)

NewFloat16FromFloat64 returns the nearest 16-bit floating-point value for x and a bool indicating whether f represents x exactly.

func NewFloat16FromString

func NewFloat16FromString(s string) Float16

NewFloat16FromString returns a new 16-bit floating-point value based on s, which contains 4 bytes in hexadecimal format.

func (Float16) Bits

func (f Float16) Bits() uint16

Bits returns the IEEE 754 binary representation of f.

func (Float16) Bytes

func (f Float16) Bytes() []byte

Bytes returns the IEEE 754 binary representation of f as a byte slice, containing 4 bytes in hexadecimal format.

func (Float16) Float32

func (f Float16) Float32() float32

Float32 returns the float32 representation of f.

func (Float16) Float64

func (f Float16) Float64() float64

Float64 returns the float64 representation of f.

func (Float16) String

func (f Float16) String() string

String returns the IEEE 754 binary representation of f as a string, 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

func NewFloat80FromBits(se uint16, m uint64) Float80

NewFloat80FromBits returns a new 80-bit floating-point value based on the sign, exponent and mantissa bits.

func NewFloat80FromBytes

func NewFloat80FromBytes(b []byte) Float80

NewFloat80FromBytes returns a new 80-bit floating-point value based on b, which contains 20 bytes in hexadecimal format.

func NewFloat80FromFloat64

func NewFloat80FromFloat64(x float64) Float80

NewFloat80FromFloat64 returns the nearest 80-bit floating-point value for x.

func NewFloat80FromString

func NewFloat80FromString(s string) Float80

NewFloat80FromString returns a new 80-bit floating-point value based on s, which contains 20 bytes in hexadecimal format.

func (Float80) BigFloat

func (f Float80) BigFloat() *big.Float

BigFloat returns the *big.Float representation of f.

func (Float80) Bits

func (f Float80) Bits() (se uint16, m uint64)

Bits returns the IEEE 754 binary representation of f, with the sign and exponent in se and the mantissa in m.

func (Float80) Bytes

func (f Float80) Bytes() []byte

Bytes returns the x86 extended precision binary representation of f as a byte slice.

func (Float80) Float64

func (f Float80) Float64() float64

Float64 returns the float64 representation of f.

func (Float80) String

func (f Float80) String() string

String returns the IEEE 754 binary representation of f as a string, containing 10 bytes in hexadecimal format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL