float16

package
v15.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 7 more Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxNum = Num{/* contains filtered or unexported fields */}
	MinNum = MaxNum.Negate()
)

Functions

This section is empty.

Types

type Num

type Num struct {
	// contains filtered or unexported fields
}

Num represents a half-precision floating point value (float16) stored on 16 bits.

See https://en.wikipedia.org/wiki/Half-precision_floating-point_format for more informations.

func FromBits

func FromBits(src uint16) Num

func FromLEBytes

func FromLEBytes(src []byte) Num

func Inf

func Inf() Num

func Max

func Max(first Num, rest ...Num) Num

Max returns the largest Decimal128 that was passed in the arguments

func Min

func Min(first Num, rest ...Num) Num

Min returns the smallest Decimal128 that was passed in the arguments

func NaN

func NaN() Num

func New

func New(f float32) Num

New creates a new half-precision floating point value from the provided float32 value.

func (Num) Abs

func (n Num) Abs() Num

func (Num) Add

func (n Num) Add(rhs Num) Num

func (Num) Cmp

func (n Num) Cmp(other Num) int

Cmp compares the numbers represented by n and other and returns:

+1 if n > other
 0 if n == other
-1 if n < other

func (Num) Div

func (n Num) Div(rhs Num) Num

func (Num) Equal

func (n Num) Equal(other Num) bool

Equal returns true if the value represented by n is == other

func (Num) Float32

func (f Num) Float32() float32

func (Num) Greater

func (n Num) Greater(other Num) bool

Greater returns true if the value represented by n is > other

func (Num) GreaterEqual

func (n Num) GreaterEqual(other Num) bool

GreaterEqual returns true if the value represented by n is >= other

func (Num) IsNaN

func (n Num) IsNaN() bool

func (Num) IsZero

func (n Num) IsZero() bool

func (Num) Less

func (n Num) Less(other Num) bool

Less returns true if the value represented by n is < other

func (Num) LessEqual

func (n Num) LessEqual(other Num) bool

LessEqual returns true if the value represented by n is <= other

func (Num) Mul

func (n Num) Mul(rhs Num) Num

func (Num) Negate

func (n Num) Negate() Num

func (Num) PutLEBytes

func (f Num) PutLEBytes(dst []byte)

func (Num) Sign

func (n Num) Sign() int

func (Num) Signbit

func (n Num) Signbit() bool

func (Num) String

func (f Num) String() string

func (Num) Sub

func (n Num) Sub(rhs Num) Num

func (Num) ToLEBytes

func (f Num) ToLEBytes() []byte

func (Num) Uint16

func (f Num) Uint16() uint16

Jump to

Keyboard shortcuts

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