Replies: 3 comments 1 reply
-
Float32 contains as the name says 32bits which is 4 bytes (2 registers), so I am not sure where you see a problem ? If you look at float64 it's the double size. Python only knows float, and do not care about the size, but at protocol level we need to. |
Beta Was this translation helpful? Give feedback.
-
Please also be aware that due to only having 32/64 bits converting to/from will often show differences on some distant decimal. "e" is defined as 2 bytes not 4. Could it be you are confusing registers with bytes, the functions are *_registers and they work on registers which is not the same as bytes. |
Beta Was this translation helpful? Give feedback.
-
@janiversen Thanks for the clarification. I was confused as the api doc on DATATYPE says:
And in the case of a FLOAT32 this value is set to 2. So it should be names I still don't understand why the convertion to registers of a max_float32 and max_float32 results in the same register values? |
Beta Was this translation helpful? Give feedback.
-
Based on the Implementation the DATATYPE FLOAT32 is represented by 2 Bytes and is packed using the pythons
f
format.Reading the pyhtons doc the pythons
f
format is defined by 4 bytes.This leads to wrong register values as we the method
convert_to_registers
and indirectly the underlyingpack
method accepts bigger numbers than those which are reflected in the result.Following small example shows the wrong behaviour:
with the following output as result:
Shouldn't the number of bytes accepted by the datatype be in sync with the struct format? In the example of a float32 this should be represented by the pyhton structs
e
format?Beta Was this translation helpful? Give feedback.
All reactions