Mail Archives: djgpp/1998/03/19/05:46:08
On Tue, Mar 17, 1998 at 01:38:06PM +0100, Fabrice ILPONSE wrote:
> Salvador Eduardo Tropea (SET) wrote:
>
> > Fabrice ILPONSE <fabrice AT trash DOT lip6 DOT fr> wrote:
> >
> > > I've downloaded the "ncurve3" program from that create curves.
It uses
> > > doubles for coordonates but I cast them to int for my purpose.
> > > Sometimes, my prog exist on FPE. I don't know why! (it's really the
> > > cast) . So i changed the doubles to floats and it works well.
> > > Question: is it a gcc bug?
> >
> > Are you sure that that's the problem?
> > Are the values correct, I mean: are valid numbers? (no infinite, etc).
> it's a good remark, I'll try to get the doubles values. But that do
not
> explain why it works now with floats! :|
Here is another way for SIGFPE (compile with -O0):
int main (void)
{
int i;
double d;
d=3e9;
i=(int)d;
return 0;
}
You'll get a SIGFPE when you want to convert a too big floating point
number to int. But if you want, you can disable this with _control87()
(you must mask bit 0). However this is not a too good solution: if you run
this program with this bit mask, you will get i=0x8000000 (which is a
negative integer!). If your problem is caused by something like this,
then you must do some extra work to use the code with integers (ie. this
is not a gcc bug.)
Laszlo
- Raw text -