information to be lost on converting int to float
David Hough
sun!Eng!dgh
Tue Aug 14 09:21:13 PDT 1990
In mixed expressions involving integer and floating types, it would be
better to slightly amend ANSI-C for NCEG by requiring that, regardless
of expression evalution mode, operands of different types always be
promoted AT LEAST to what I call the "smallest encompassing" floating-point
type (but not to exceed long double!), which for IEEE systems is...
float & 16-bit int float
float & 32-bit int double
double & 32 bit int double
double & 64 bit int long double
long double & int long double
Thus "promotion" never entails rounding except possibly after you've
promoted everything to long double.
I don't think this would cause any trouble for IEEE, VAX, or 370
architectures, but it might be a problem for Cray if there are
peculiarities of integer arithmetic like those on the CDC-6600.
I'd be happy to limit this requirement to IEEE 754 implementations.
More information about the Numeric-interest
mailing list