I know the data types 'char','short','long', and 'int' can be signed or unsigned... but why can't 'float'? I don't see why not? But when I experiment with it on the compilier, an error occurs![]()
This is a discussion on Why can't 'float' variables be assigned to signed or unsigned? within the C++ Programming forums, part of the General Programming Boards category; I know the data types 'char','short','long', and 'int' can be signed or unsigned... but why can't 'float'? I don't see ...
I know the data types 'char','short','long', and 'int' can be signed or unsigned... but why can't 'float'? I don't see why not? But when I experiment with it on the compilier, an error occurs![]()
Probably because the built-in types were specified with known systems of representation in mind, and the relevant floating point systems don't fit the notion of an unsigned float (or unsigned double).Originally Posted by cplusplusnoob
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
So the question becomes why didn't the IEEE 754 standard include unsigned floating-point types. Possibly to simplify the hardware implementation. Assuming for an unsigned type that the sign bit would be allocated to the mantissa, the hardware (circa 1985) would have to deal with two sizes of mantissa. We can also assume that programmers have not been demanding an unsigned float (and one extra bit of precision) since no update has incorporated unsigned floats.