Conversion from negative float to unsigned int

Doug Gwyn (VLD/VMB) uunet!BRL.MIL!gwyn
Tue Mar 16 12:50:54 PST 1993


As footnote 29 says, -1.0 is not within the range of floating values for
which a floating type can be converted to unsigned integral type in a
strictly conforming program.  -1 is not representable in an unsigned
integral type.

I think it would be nice if the implementation produced an exception so
that this case could be caught early in the development cycle, but that
seems unlikely for most implementations.  Presumably what one gets in
most cases would be whatever the algorithm that works most efficiently
for the portable range happens to produce when applied to -1.0.  It could
be nearly anything, most likely one of the choices you suggested.



More information about the Numeric-interest mailing list