[issue45032] struct.unpack() returns NaN

2021-08-27 Thread Terry J. Reedy
Terry J. Reedy added the comment: Jorge, next time you have questions about how to use a module (and struct is fairly advanced), please ask on an appropriate forum, such as python-list. Then Steven's nice answer could be read by 100s of people instead of likely less than 10. I looked as

[issue45032] struct.unpack() returns NaN

2021-08-27 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug, and I'm unconvinced that it needs a documentation change. If you are using struct to assemble values, you need to know the meaning of the struct format. It returns a float NAN because you give it the bit pattern of a NAN. For C singles

[issue45032] struct.unpack() returns NaN

2021-08-27 Thread Jorge Rojas
New submission from Jorge Rojas : Hi all! I have this case when trying to get a float value applying pack to these integer values: struct.unpack('f', struct.pack('HH', 0, 32704)) This happens when executing the unpack function to a float format, from a bit-array where the sign bit is not in