Float16

For conceptual model usage and type mapping, see:

class pyrogue.Float16(bitSize)[source]

Model class for 16-bit half-precision floating point numbers.

Parameters:
  • bitSize (int) – Number of bits being represented. Must be 16.

  • args (Any)

  • kwargs (Any)

Return type:

Any

pytype

alias of float

toBytes(value)[source]

Convert a python float value to a byte array.

Parameters:

value (float) – Python float value to convert.

Returns:

Byte array representation of the value.

Return type:

bytearray

Notes

Uses struct.pack with IEEE 754 round-to-nearest-even. The C++ Block path (floatToHalf) uses truncation instead, so values that fall on a rounding boundary may differ by 1 ULP between the two paths.

fromBytes(ba)[source]

Convert a byte array to a python float value.

Parameters:

ba (bytes) – Byte array to extract value from.

Returns:

Python value.

Return type:

float

fromString(string)[source]

Convert a string to a python float value.

Parameters:

string (str) – String representation of the value.

Returns:

Python value.

Return type:

float

minValue()[source]

Return the minimum 16-bit float (-65504).

Return type:

float

maxValue()[source]

Return the maximum 16-bit float (65504).

Return type:

float

class pyrogue.Float16BE(bitSize)[source]

Model class for 16-bit floats stored as big endian

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any