Ocean
Ocean::Float16 Class Reference

Definition of a 16-bit float type. More...

Public Member Functions

 Float16 ()=default
 Default constructor. More...
 
 Float16 (const uint16_t sign, const uint16_t fraction, const uint16_t exponent)
 Creates a new 16-bit float. More...
 
 Float16 (const uint16_t binary)
 Creates a new 16-bit float based on a 16-bit binary value. More...
 
uint16_t binary () const
 Returns the binary representation of this 16-bit float value. More...
 
 operator float () const
 Cast operator to 32-bit float. More...
 
Float16 operator- () const
 Negates the 16-bit float value. More...
 
bool operator== (const Float16 &second) const
 Returns whether two 16-bit float values are identical. More...
 
bool operator!= (const Float16 &second) const
 Returns whether two 16-bit float values are not identical. More...
 

Static Public Member Functions

static Float16 infinity ()
 Returns +infinity. More...
 

Protected Attributes

union {
   uint16_t   binary_ = 0u
 The binary representation. More...
 
   struct {
      uint16_t   fraction_: 10
 The mantissa composed of 10 bits. More...
 
      uint16_t   exponent_: 5
 The exponent composed of 5 bits. More...
 
      uint16_t   sign_: 1
 The sign composed of 1 bit. More...
 
   }   ieee_
 The struct with the IEEE representation. More...
 
data_
 Union allowing to access the binary representation or the IEEE representation. More...
 

Detailed Description

Definition of a 16-bit float type.

Constructor & Destructor Documentation

◆ Float16() [1/3]

Ocean::Float16::Float16 ( )
default

Default constructor.

◆ Float16() [2/3]

Ocean::Float16::Float16 ( const uint16_t  sign,
const uint16_t  fraction,
const uint16_t  exponent 
)
inline

Creates a new 16-bit float.

Parameters
signThe 1-bit sign to be used, with range [0, 1]
fractionThe 10-bit fraction to be used, with range [0, 1023]
exponentThe 5-bit exponent to be used, with range [0, 31]

◆ Float16() [3/3]

Ocean::Float16::Float16 ( const uint16_t  binary)
inlineexplicit

Creates a new 16-bit float based on a 16-bit binary value.

Parameters
binaryThe binary value to be used

Member Function Documentation

◆ binary()

uint16_t Ocean::Float16::binary ( ) const
inline

Returns the binary representation of this 16-bit float value.

Returns
The value's binary representation

◆ infinity()

Float16 Ocean::Float16::infinity ( )
inlinestatic

Returns +infinity.

Returns
The 16-bit float representing positive infinity

◆ operator float()

Ocean::Float16::operator float ( ) const
explicit

Cast operator to 32-bit float.

Returns
The 32-bit float representation

◆ operator!=()

bool Ocean::Float16::operator!= ( const Float16 second) const
inline

Returns whether two 16-bit float values are not identical.

Parameters
secondThe second value to compare
Returns
True, if so

◆ operator-()

Float16 Ocean::Float16::operator- ( ) const
inline

Negates the 16-bit float value.

Returns
The negated value

◆ operator==()

bool Ocean::Float16::operator== ( const Float16 second) const
inline

Returns whether two 16-bit float values are identical.

Parameters
secondThe second value to compare
Returns
True, if so

Field Documentation

◆ binary_

uint16_t Ocean::Float16::binary_ = 0u

The binary representation.

◆ 

union { ... } Ocean::Float16::data_

Union allowing to access the binary representation or the IEEE representation.

◆ exponent_

uint16_t Ocean::Float16::exponent_

The exponent composed of 5 bits.

◆ fraction_

uint16_t Ocean::Float16::fraction_

The mantissa composed of 10 bits.

◆ 

struct { ... } Ocean::Float16::ieee_

The struct with the IEEE representation.

◆ sign_

uint16_t Ocean::Float16::sign_

The sign composed of 1 bit.


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