floatToByte

fun floatToByte(f: Float, numMantissaBits: Int, zeroExp: Int): Byte

Converts a 32 bit float to an 8 bit float.

Values less than zero are all mapped to zero.

Values are truncated (rounded down) to the nearest 8 bit value.

Values between zero and the smallest representable value are rounded up.

Return

the 8 bit float representation

Parameters

f

the 32 bit float to be converted to an 8 bit float (byte)

numMantissaBits

the number of mantissa bits to use in the byte, with the remainder to be used in the exponent

zeroExp

the zero-point in the range of exponent values