Re: inconsistent for() and while() behavior when using floating point

From: Warner Losh <imp_at_bsdimp.com>
Date: Mon, 15 Jan 2018 08:52:54 -0700
On Mon, Jan 15, 2018 at 7:38 AM, Yuri Pankov <yuripv_at_icloud.com> wrote:

> Is this a known problem with loops and floating point numbers?
>

Yes. Many exact fractions in base-10 aren't exact in base-2, so you get
accumulation of errors based on the tiny difference and see behavior like
this. This is totally expected. You have to work around the problem using a
computation method that doesn't accumulate errors.

Warner
Received on Mon Jan 15 2018 - 14:52:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:14 UTC