finding out the precision of floats

Bart Ogryczak B.Ogryczak at gmail.com
Wed Feb 28 12:19:09 EST 2007


On Feb 28, 3:53 pm, "John Machin" <sjmac... at lexicon.net> wrote:
> On Feb 28, 10:38 pm, "BartOgryczak" <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".

YPB? Have you ever heard of real-time systems?

> 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.

YPB? Anyone with half a brain knows, that you can either express rate
as 0.07 and do all those ridiculous conversions above, or express it
as 1.07 and apply it directly.

> > BTW, math.* functions do not return Decimals.
>
> For which Bell Labs be praised, but what's your point?

That Decimal is useless, for anything but invoices.







More information about the Python-list mailing list