float16

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 7 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package float16 implements the IEEE 754 half-precision floating-point format (binary16).

Index

Constants

View Source
const SmallestNonzero = Float16(0x0001)

SmallestNonzero is the smallest nonzero denormal value for float16. For IEEE 754 binary16, the smallest non-zero denormalized value is 2^-24, which is approximately 5.96e-8.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float16

type Float16 uint16

Float16 (half-precision floating-point) format is a computer number format occupying 16 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point. This format is the IEEE 754 half-precision floating-point format (binary16).

func From

func From[T numberTypes](value T) Float16

From converts the value from a standard numeric type to Float16.

func FromBits

func FromBits(uint16 uint16) Float16

FromBits convert an uint16 to a Float16.

func FromFloat32

func FromFloat32(x float32) Float16

FromFloat32 converts a float32 to a Float16.

func FromFloat32s

func FromFloat32s(values ...float32) []Float16

FromFloat32s converts a variadic list of float32s to a []Float16.

func FromFloat64

func FromFloat64(x float64) Float16

FromFloat64 converts a float64 to a Float16.

func FromNumbers

func FromNumbers[T numberTypes](values ...T) []Float16

FromNumbers converts a variadic list of numeric values to a []Float16.

func Inf

func Inf(sign int) Float16

Inf returns a Float16 with an infinity value with the specified sign. A sign >= returns positive infinity. A sign < 0 returns negative infinity.

func NaN

func NaN() Float16

NaN returns a Float16 with a NaN value.

func (Float16) Bits

func (f Float16) Bits() uint16

Bits convert Float16 to an uint16.

func (Float16) Float32

func (f Float16) Float32() float32

Float32 converts the Float16 to a float32.

func (Float16) Float64

func (f Float16) Float64() float64

Float64 converts the Float16 to a float64.

func (Float16) Neg

func (f Float16) Neg() Float16

Neg returns the negative of the current value.

func (*Float16) SetFloat32

func (f *Float16) SetFloat32(v float32)

SetFloat32 sets the values from a float32.

func (*Float16) SetFloat64

func (f *Float16) SetFloat64(v float64)

SetFloat64 sets the values from a float64.

func (Float16) String

func (f Float16) String() string

String implements fmt.Stringer, and prints a float representation of the Float16.

Jump to

Keyboard shortcuts

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