Behavior of numeric::to_int() and numeric::to_long()

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Tue Oct 1 16:29:02 CEST 2002


On Tue, 1 Oct 2002, Roberto Bagnara wrote:
> What I am saying is that, instead of writing "Not a 32-bit integer..."
> and exiting, you could throw an exception.  This would not impede
> performance, since the test now controlling the printing would then
> control the throw.

Unfortunately this is not true since it would prohibit compilation of CLN
with the option -fno-exceptions.  CLN is designed in such a way that
ranges must be checked before the calls are made for reasons of
efficiency.  Apart from having a register less maybe, the problematic part
is the dtors' overhead needed for stack unwinding.

>                     The change I am proposing would make debugging
> much easier and would make possible recovering from the error (and
> this is the thing that is very important to us).

You'll have to check yourself at those places where an over/underflow may
happen for numeric::to_int() and numeric::to_long(), I'm afraid.  The
other such checks you were proposing will be applied to CVS in some
minutes, though.

Regards
    -richy.
-- 
Richard B. Kreckel
<Richard.Kreckel at GiNaC.DE>
<http://www.ginac.de/~kreckel/>




More information about the GiNaC-list mailing list