This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: float to int conversion


Andrew Haley [aph@redhat.com] wrote:
> What do you think the conversion should do in this case?  I find
> the current behaviour to be the least surprising.

Well, it should at least give consistent values regardless of
the level of optimization being used. I'm even having a more complex
C++ program that gives different values for each of the optimization
levels -O0, -O1 and -O2! I'd be really surprised if this doesn't
come to a surprise to anyone ;-).

To me (and the colleagues I've talked to), the "most expected" behaviour
would be:

any flaot equal to or bigger than the biggest integer -> biggest integer
any flaot equal to or smaller than the smallest integer -> smallest integer

This could even be driven further:

INF+ -> biggest integer
INF- -> smallest integer

and just to have one consistent definition for that:

QNAN -> 0
SNAN -> floating point exception

But imho, anything, even "undefined (but fixed)", would be better than
"varying depending on the level of optimization". 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]