Open disconnect3d opened 5 years ago
Some nice things we want here:
1) Ability to create the float/double from its binary representation (e.g. F32.from_le(0x1234)
should create the float from its little-endian representation, .from_be(..)
from big endian) etc.
2) Methods to convert to int value and a string binary representation
In [12]: bin(ctypes.c_float(float('NaN')))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[12], line 1
----> 1 bin(ctypes.c_float(float('NaN')))
TypeError: 'c_float' object cannot be interpreted as an integer
3) Support for special values (NaN, -0, -inf, +inf), it should probably work out of the box:
In [10]: ctypes.c_float(float('NaN'))
Out[10]: c_float(nan)
4) Support for various math operators, e.g., this should just work:
In [11]: ctypes.c_float(float('NaN')) + 2
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 ctypes.c_float(float('NaN')) + 2
TypeError: unsupported operand type(s) for +: 'c_float' and 'int'
Even when
cint
stays for integers, it would be cool to add support for float/double types.