View Source Modbux.IEEE754 (Modbux v0.3.11)
IEEE754 float helper
Based on https://www.h-schmidt.net/FloatConverter/IEEE754.html.
Summary
Functions
Converts a couple of 16-bit registers to IEEE754 float.
Converts a couple of 16-bit registers to IEEE754 float.
Converts a list of 2n 16-bit registers to a IEEE754 floats list.
Converts a IEEE754 float to a couple of 16-bit registers.
Converts a list of IEEE754 floats to a list of 2n 16-bit registers.
Functions
Converts a couple of 16-bit registers to IEEE754 float.
Example
+5.0 = IEEE754.from_2_regs(0x40a0, 0x0000, :be)
Converts a couple of 16-bit registers to IEEE754 float.
Example
+5.0 = IEEE754.from_2_regs(0x40a0, 0x0000, :be)
Converts a list of 2n 16-bit registers to a IEEE754 floats list.
Example
[-5.0, +5.0] = IEEE754.from_2n_regs([0xc0a0, 0x0000, 0x40a0, 0x0000], :be)
Converts a IEEE754 float to a couple of 16-bit registers.
Example
[0xc0a0, 0x0000] = IEEE754.to_2_regs(-5.0)
Converts a list of IEEE754 floats to a list of 2n 16-bit registers.
Example
[0xc0a0, 0x0000, 0x40a0, 0x0000] = IEEE754.to_2n_regs([-5.0, +5.0])