finding out the precision of floats

John Machin sjmachin at lexicon.net
Wed Feb 28 09:53:39 EST 2007


On Feb 28, 10:38 pm, "Bart Ogryczak" <B.Ogryc... at gmail.com> wrote:

> [1] eg. consider calculating interests rate, which often is defined as
> math.pow(anualRate,days/365.0).

In what jurisdiction for what types of transactions? I would have
thought/hoped that the likelihood that any law, standard or procedure
manual would define an interest calculation in terms of the C stdlib
would be somewhere in the region of math.pow(epsilon, HUGE), not
"often".

More importantly, the formula you give is dead wrong. The correct
formula for converting an annual rate of interest to the rate of
interest to be used for n days (on the basis of 365 days per year) is:

(1 + annual_rate) ** (n / 365.0) - 1.0
or
math.pow(1 + annual_rate, n / 365.0) - 1.0
if you prefer.

> BTW, math.* functions do not return Decimals.

For which Bell Labs be praised, but what's your point?

Cheers,
John




More information about the Python-list mailing list