is there a symbolic infinity
Andreas Fabri
Andreas.Fabri at sophia.inria.fr
Fri Oct 28 22:28:52 CEST 2005
Torbjorn Granlund wrote:
> Andreas Fabri <Andreas.Fabri at sophia.inria.fr> writes:
>
> is there a means to express the biggest and the smallest
> number of each GMP number type in a symbolic way?
>
> No, tghere is no notion of infinity in GMP.
>
> As a matter of fact, there is no overflow detection. In practice,
> one should normally get a memory allocation error, not numerical
> overflow in such situations.
To have a notion of infinity is just needed, if your numbers
can go towards infinity without overflow.
For the number types that can overflow, there is just
no notion of infinity, but the biggest representable
number.
The idea of the numeric_limits class is that
one can write code that can take care of this
different behaviour.
Say for gmpz, as representationwise it is a
small number with a chain of limbs, you would
have just one limb and you decide that the
semantics of the pointer to this limb is infinity.
The comparison between two numbers must then
first check that one of the two is not infinity.
and so on.
Does such a feature request sound reasonable?
Best regards,
andreas
> But it is not safe to approach the limit of 2^32-1 bits on a 32-bit
> machine. One might get garbage results.
>
> --
> Torbjörn
>
More information about the gmp-discuss
mailing list