C++ factorial error reporting

Niels Möller nisse at lysator.liu.se
Thu Jan 1 14:57:40 UTC 2015

Marc Glisse <marc.glisse at inria.fr> writes:

> I don't think it makes that much sense to have a
> different exception depending on who notices that the number is too
> big,

I'm not familiar with the "standard exceptions" in C++, so I can't say
which is the most appropriate exception. But at least I agree that it
makes sense to use the *same* exception for all inputs which are too
large for gmp's factorial function to complete successfully.

In theory makes some sense to differentiate between those errors that
are solvable by buying more RAM and/or storage, and those that would
also require changes to GMP. But in practice I doubt this is a useful
distinction for the factorial function. Neither (2^64)! nor (2^64-1)!
are equally unlikely to be computable in practice (125 exabyte needed to
store the result, if I apply Stirling's formula correctly).


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list