Modbus.IEEE754 (modbus v0.3.9)

IEEE754 float helper

Based on https://www.h-schmidt.net/FloatConverter/IEEE754.html.

Link to this section 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.

Link to this section Functions

Link to this function

from_2_regs(list, atom)

Converts a couple of 16-bit registers to IEEE754 float.

Example

+5.0 = IEEE754.from_2_regs(0x40a0, 0x0000, :be)
Link to this function

from_2_regs(w0, w1, atom)

Converts a couple of 16-bit registers to IEEE754 float.

Example

+5.0 = IEEE754.from_2_regs(0x40a0, 0x0000, :be)
Link to this function

from_2n_regs(list, endianness)

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)
Link to this function

to_2_regs(f, atom)

Converts a IEEE754 float to a couple of 16-bit registers.

Example

[0xc0a0, 0x0000] = IEEE754.to_2_regs(-5.0)
Link to this function

to_2n_regs(list, endianness)

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])