Exception when casting doubles to ints
alan_baa at hotmail.com
Fri Jan 7 01:11:06 PST 2005
>John Tytgat wrote:
>In message <BAY101-F254E3ED3F8DDFE11900C51F0930 at phx.gbl> you wrote:
> > It appears that when a double that is larger than the maximum
> > int is cast to an int a floating point exception occurs. On cygwin
> > you do not get an exception, and as the code where I found the
> > problem was in lua I suspect other linux/unix variations also do not
> > raise an exception. Can anyone confirm the unix behaviour?
> > If this is the case should the RISC OS gcc match what unix does?
>Actually I don't mind this being the default behaviour because it is
>something pretty undefined what int value you would have if no exception
>would be raised.
The default behaviour does make sense to me as well. However it does
appear that it may be different from the behaviour generated by GCC on
>But I think your question is around the header fenv.h (cfr.
>for more info). I understand from it that the default floating point
>exception behaviour is not specified but that you can change it with
>limitations using the fe*() functions. If your lua program is using
>those fe*() and you think UnixLib is not behaving like the above mentioned
>specification, feel free to let us know the details.
The lua program and the test program I included don't use the fenv.h
at all. Having looked at the documentation above I can't see how they help
as they seem to be just setting and getting the status registers and not
modifying the behaviour.
Have I misread the documentation? If so, can you show me the code I
need to add to a program?
If not, is there any other routine I can add to the program to modify how
casting from double to int is handled.
More information about the gcc