Floating point exponentiation

Chris Gast cmgast at gmail.com
Tue Mar 23 16:17:43 CET 2010


Thanks everyone, for your comments.

A bit of clarification for anyone who's interested:  by "big" I mean "large
in (negative) exponent."  The numbers are actually quite small.  If you're
familiar with likelihood functions, specifically of multinomial
distributions, then you know that powers of products of probabilities can
get quite small, quite quickly.  For various reasons, I cannot work with the
log-likelihood, but I find it more convenient to first compute the
log-likelihood, then exponentiate the result.


Chris




-----------------------------
Chris Gast
cmgast at gmail.com


On Tue, Mar 23, 2010 at 3:15 AM, Torbjorn Granlund <tg at gmplib.org> wrote:

> David Gillies <daggillies at gmail.com> writes:
>
>  What does 'big' mean? Forget floating point: exp(n) for an n that fits
>  in a uint32_t will exhaust, or as near as makes no difference, memory
>  in any normal machine. exp(2^32) is around the billion-byte mark in
>  radix 256 (eight bit binary.) Even if you can fit your operand (and
>  its destination) in main memory, any computation beyond O(n) is going
>  to be silly. 64 bit? Nah. The exponent ceases to be representable in a
>  first-order scheme. The mantissa waved bye-bye through the back window
>  many miles back.
>
> I don't understand this comment.
>
> We're talking about floating-point numbers here, not integers.  While
> e^2^32 is a large number, it will be possible to represent
> approximatively with GMP on a 64-bit machine.  (The exponent type is
> there typically 64 bits.)  It will not need more memory than specified
> for the destination variable.
>
> I also do not agree with the statement that computations in \Omega(n)
> are silly for numbers with billion digit mantissas.  I assume this is
> what you mean with "beyond O(n)".
>
> --
> Torbjörn
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>


More information about the gmp-discuss mailing list