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
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
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.
The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss