Re: Ask for recommended module for precise number




"Tom" <chi.lun@xxxxxxxxx>
..
..
>
> Currently I am writing a mathematic module which has multiplications
> and divisions of very small and big numbers. I use log() and exp() to
> handle those problem, but it makes the codes less understandable and
> intitutive.
>
> Therefore, I am planning to write a new module to automatically convert
> the number into log space (internally) if it is too big or too small.
>
> I hope to ask whether there is already some modules in PERL or C
> perform this tasks.

I think " multiplications and divisions of very small and big numbers"
implies "multiple precision arithmetic" - and there are a number of modules
that handle multiple precision arithmetic. These include the Math::Big*
modules (as already mentioned), Math::GMP, Math::Pari and Math::MPFR (to
name a few more).

However, I don't think that any of those modules performs multiple precision
arithmetic (or, in your terms,"multiplications and divisions of very small
and big numbers") by automatically converting "the number into log space"
(or exp space, ftm).

Seems to me that log() and exp() suffer from not being able to precisely
represent many numbers.

For example, the modules mentioned above can all represent *exactly* the
value
''12345678902345678901234567890234567890234567811111190555555555555555555555
5555555555552345678901234567890234567890234567890234567890123456789023456789
0"

How do you represent *exactly* that value by using log() and/or exp() ?

Cheers,
Rob


.



Relevant Pages

  • Re: COMPLEX
    ... This time, it's with EXP. ... Gives an INVALIDOP condition when the imaginary ... part of the operand is a multiple of PI. ...
    (comp.lang.pl1)
  • Re: MOD
    ... digits, but not so many for multiply and divide. ... Tlat's wholly irrelevant. ... It's even easier to do multiple precision in decimal than binary. ...
    (comp.lang.pl1)