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

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


On Tue, 1 Oct 2002, Roberto Bagnara wrote:
> These methods, and the corresponding functions taking
> the argument as a const numeric& parameter, when something
> goes wrong print a line of the form
>
> Not a 32-bit integer: -9223372028264841216
>
> on cerr and exit the program.  Wouldn't throwing a
> suitable standard exception (like std::domain_error)
> be a better option?

Not really.  We want them to be fast.  They are intended for use in main
loops only and if you look into the code you'll see that we don't even
check whether they are actual integers.  The programmer should care about
that...

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




More information about the GiNaC-list mailing list