int/float/double overflow / underflow

int/float/double overflow / underflow

Post by Victor Bazaro » Wed, 23 Aug 2000 04:00:00




> Hello

>         Does anyone know how to detect for int/float/double overflow and
> underflow in c++ (without resort to using a larger representation)?

I think it's hardware-specific.  IIRC, Intel x86 has a signal that
is raised when FP overflow occurs.  You could trap it using signal().

Victor
--
Please remove capital A's from my address when replying by mail

 
 
 

int/float/double overflow / underflow

Post by Ron Natali » Thu, 24 Aug 2000 04:00:00




> > Hello

> >         Does anyone know how to detect for int/float/double overflow and
> > underflow in c++ (without resort to using a larger representation)?

> I think it's hardware-specific.  IIRC, Intel x86 has a signal that
> is raised when FP overflow occurs.  You could trap it using signal().

Yep, and with respect to unsigneds, it's ILLEGAL for the compiler to trap
(it's required to just wrap around).  I think it's unspecified for signed
ints, and most machines DONT trap (we used to have one that did, but they
quickly disabled it because there's a lot of code that expects ints to
wrap).