
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/30/2010 08:23 AM, Peter Dimov wrote:
How does one mix code wanting exceptions with code not wanting them?
Pretty easy (bad_alloc aside (*)), since the only way to get an exception when doing integer operations is to divide by zero (**). So code not wanting exceptions needs only not divide by zero - problem solved. This of course assumes that the exceptions are not delayed via a signaling NaN with the express purpose of making your life difficult by turning unary op+/- into a throwing operation.
Which is only a problem if you're doing something that produces a NaN. In XInt, that's rare, and all such cases are very carefully documented.
(*) And by the way, out of memory is not overflow. It's possible to run out of memory while computing an integer that is smaller than another integer that already has been computed. This is not what overflow means.
If that was aimed at XInt, note its purpose: it's intended to allow calculation with numbers of arbitrary length, up to the memory size of the system. If the system can't provide enough memory for it at some point, that *is* an overflow -- the number is too large to represent. That definition is already used in Boost as well, in the Boost.Math library: "Overflow Error: Occurs when the result is either infinite, or too large to represent in the numeric type being returned by the function." - -- Chad Nelson Oak Circle Software, Inc. * * * -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkuyCXYACgkQp9x9jeZ9/wQwDQCg+Gjt+ZCMetMd/2OgZCIhNpBK pNUAoOohZZfJyo3+/gCkduC6yNAqMeK6 =sZPu -----END PGP SIGNATURE-----