[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: precision of floor(a/b)
From: |
Martin Helm |
Subject: |
Re: precision of floor(a/b) |
Date: |
Tue, 6 Apr 2010 13:23:53 +0200 |
User-agent: |
KMail/1.12.4 (Linux/2.6.31.12-0.2-desktop; KDE/4.3.5; x86_64; ; ) |
Am Dienstag, 6. April 2010 12:57:19 schrieb CdeMills:
> To avoid implementation-dependent problems, I suggest to compute your loop
> as
> alpha_min = 0;
> alpha_max = 6;
> alpha_step = 0.1;
> for alpha = alpha_min : alpha_max,
> # <do some stuff with alpha*alpha_step>
> endfor
> This way, the latest processed value will be 6*0.1, and not either .5 or
> .6, depending on the way the equality test is performed. It's less
> elegant, requires one more multiplication or variable, but it's
> predictable.
>
> Regards
>
> Pascal
>
why not simply
n = number of intervals
for alpha = linspace(alpha_min, alpha_max, n+1),
.. work with alpha
endfor
- mh
Re: precision of floor(a/b), Scott Carter, 2010/04/05