Halide
Halide::float16_t Struct Reference

Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in software. More...

#include <Float16.h>

Public Member Functions

EXPORT float16_t ()
 Construct a float16_t with the bits initialised to 0. More...
 
EXPORT operator float () const
 Cast to float. More...
 
EXPORT operator double () const
 Cast to double. More...
 
EXPORT float16_t (const float16_t &)=default
 
EXPORT float16_toperator= (const float16_t &)=default
 
EXPORT float16_t operator- () const
 Return a new float16_t with a negated sign bit. More...
 
EXPORT uint16_t to_bits () const
 Returns the bits that represent this float16_t. More...
 
Constructors
EXPORT float16_t (float value)
 Construct from a float, double, or int using round-to-nearest-ties-to-even. More...
 
EXPORT float16_t (double value)
 Construct from a float, double, or int using round-to-nearest-ties-to-even. More...
 
EXPORT float16_t (int value)
 Construct from a float, double, or int using round-to-nearest-ties-to-even. More...
 
EXPORT float16_t operator+ (float16_t rhs) const
 Arithmetic operators. More...
 
EXPORT float16_t operator- (float16_t rhs) const
 Arithmetic operators. More...
 
EXPORT float16_t operator* (float16_t rhs) const
 Arithmetic operators. More...
 
EXPORT float16_t operator/ (float16_t rhs) const
 Arithmetic operators. More...
 
EXPORT bool operator== (float16_t rhs) const
 Comparison operators. More...
 
EXPORT bool operator!= (float16_t rhs) const
 Comparison operators. More...
 
EXPORT bool operator> (float16_t rhs) const
 Comparison operators. More...
 
EXPORT bool operator< (float16_t rhs) const
 Comparison operators. More...
 
EXPORT bool operator>= (float16_t rhs) const
 Comparison operators. More...
 
EXPORT bool operator<= (float16_t rhs) const
 Comparison operators. More...
 
EXPORT bool is_nan () const
 Properties. More...
 
EXPORT bool is_infinity () const
 Properties. More...
 
EXPORT bool is_negative () const
 Properties. More...
 
EXPORT bool is_zero () const
 Properties. More...
 

Static Public Member Functions

Convenience "constructors"
static EXPORT float16_t make_zero (bool positive)
 Get a new float16_t that represents zero. More...
 
static EXPORT float16_t make_infinity (bool positive)
 Get a new float16_t that represents infinity. More...
 
static EXPORT float16_t make_nan ()
 Get a new float16_t that represents NaN (not a number) More...
 
static EXPORT float16_t make_from_bits (uint16_t bits)
 Get a new float16_t with the given raw bits. More...
 

Detailed Description

Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in software.

This type is enforced to be 16-bits wide and maintains no state other than the raw IEEE754 binary16 bits so that it can passed to code that checks a type's size and used for buffer_t allocation.

Definition at line 17 of file Float16.h.

Constructor & Destructor Documentation

◆ float16_t() [1/5]

EXPORT Halide::float16_t::float16_t ( float  value)
explicit

Construct from a float, double, or int using round-to-nearest-ties-to-even.

Out-of-range values become +/- infinity.

◆ float16_t() [2/5]

EXPORT Halide::float16_t::float16_t ( double  value)
explicit

Construct from a float, double, or int using round-to-nearest-ties-to-even.

Out-of-range values become +/- infinity.

◆ float16_t() [3/5]

EXPORT Halide::float16_t::float16_t ( int  value)
explicit

Construct from a float, double, or int using round-to-nearest-ties-to-even.

Out-of-range values become +/- infinity.

◆ float16_t() [4/5]

EXPORT Halide::float16_t::float16_t ( )

Construct a float16_t with the bits initialised to 0.

This represents positive zero.

◆ float16_t() [5/5]

EXPORT Halide::float16_t::float16_t ( const float16_t )
default

Member Function Documentation

◆ operator float()

EXPORT Halide::float16_t::operator float ( ) const
explicit

Cast to float.

◆ operator double()

EXPORT Halide::float16_t::operator double ( ) const
explicit

Cast to double.

◆ operator=()

EXPORT float16_t& Halide::float16_t::operator= ( const float16_t )
default

◆ make_zero()

static EXPORT float16_t Halide::float16_t::make_zero ( bool  positive)
static

Get a new float16_t that represents zero.

Parameters
positiveif true then returns positive zero otherwise returns negative zero.

◆ make_infinity()

static EXPORT float16_t Halide::float16_t::make_infinity ( bool  positive)
static

Get a new float16_t that represents infinity.

Parameters
positiveif true then returns positive infinity otherwise returns negative infinity.

◆ make_nan()

static EXPORT float16_t Halide::float16_t::make_nan ( )
static

Get a new float16_t that represents NaN (not a number)

◆ make_from_bits()

static EXPORT float16_t Halide::float16_t::make_from_bits ( uint16_t  bits)
static

Get a new float16_t with the given raw bits.

Parameters
bitsThe bits conformant to IEEE754 binary16

◆ operator-() [1/2]

EXPORT float16_t Halide::float16_t::operator- ( ) const

Return a new float16_t with a negated sign bit.

◆ operator+()

EXPORT float16_t Halide::float16_t::operator+ ( float16_t  rhs) const

Arithmetic operators.

◆ operator-() [2/2]

EXPORT float16_t Halide::float16_t::operator- ( float16_t  rhs) const

Arithmetic operators.

◆ operator*()

EXPORT float16_t Halide::float16_t::operator* ( float16_t  rhs) const

Arithmetic operators.

◆ operator/()

EXPORT float16_t Halide::float16_t::operator/ ( float16_t  rhs) const

Arithmetic operators.

◆ operator==()

EXPORT bool Halide::float16_t::operator== ( float16_t  rhs) const

Comparison operators.

◆ operator!=()

EXPORT bool Halide::float16_t::operator!= ( float16_t  rhs) const
inline

Comparison operators.

Definition at line 91 of file Float16.h.

References EXPORT, operator<(), and operator>().

◆ operator>()

EXPORT bool Halide::float16_t::operator> ( float16_t  rhs) const

Comparison operators.

Referenced by operator!=().

◆ operator<()

EXPORT bool Halide::float16_t::operator< ( float16_t  rhs) const

Comparison operators.

Referenced by operator!=().

◆ operator>=()

EXPORT bool Halide::float16_t::operator>= ( float16_t  rhs) const
inline

Comparison operators.

Definition at line 94 of file Float16.h.

◆ operator<=()

EXPORT bool Halide::float16_t::operator<= ( float16_t  rhs) const
inline

Comparison operators.

Definition at line 95 of file Float16.h.

References EXPORT, is_infinity(), is_nan(), is_negative(), is_zero(), and to_bits().

◆ is_nan()

EXPORT bool Halide::float16_t::is_nan ( ) const

Properties.

Referenced by operator<=().

◆ is_infinity()

EXPORT bool Halide::float16_t::is_infinity ( ) const

Properties.

Referenced by operator<=().

◆ is_negative()

EXPORT bool Halide::float16_t::is_negative ( ) const

Properties.

Referenced by operator<=().

◆ is_zero()

EXPORT bool Halide::float16_t::is_zero ( ) const

Properties.

Referenced by operator<=().

◆ to_bits()

EXPORT uint16_t Halide::float16_t::to_bits ( ) const

Returns the bits that represent this float16_t.

An alternative method to access the bits is to cast a pointer to this instance as a pointer to a uint16_t.

Referenced by operator<=().


The documentation for this struct was generated from the following file: