Problem with float output in exponential: different from what was written
$ /usr/local/bin/mbpoll -t4:float -0 -B -1 -q -r 10 127.0.0.1 -p 1502 -- 1269349 Written 1 references.
$ /usr/local/bin/mbpoll -t4:float -0 -B -1 -q -r 10 127.0.0.1 -p 1502 -- Polling slave 1... [10]: 1.26935e+06
$ /usr/local/bin/mbpoll -t4:hex -c2 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 -- Polling slave 1... [10]: 0x499A [11]: 0xF328
As you can see - if I convert read (output to shell) value "1.26935e+06" to normal number, it will be 1269350 instead of 1269349. Using online IEEE-754 converter hex is decoded normally to 1269349. Why is it displayed in exponential form?
If I do conversation from hex to iee-754 float in bash, I get correct value:
$ /usr/local/bin/mbpoll -t4:float -0 -B -1 -q -r 10 127.0.0.1 -p 1502 -- Polling slave 1... [10]: 1.26935e+06
$ /usr/local/bin/mbpoll -t4:int -0 -B -1 -q -r 10 127.0.0.1 -p 1502 -- Polling slave 1... [10]: 1234891560
$ /usr/local/bin/mbpoll -t4:hex -c2 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 -- Polling slave 1... [10]: 0x499A [11]: 0xF328
$ printf '%x\n' $(/usr/local/bin/mbpoll -t4:int -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR == 2 {print $2}') 499af328 $ printf '%x\n' $(/usr/local/bin/mbpoll -t4:int -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR == 2 {print $2}') | python3 -c 'import struct; print(struct.unpack("!f", bytes.fromhex(input()))[0])' 1269349.0