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

Warner Losh imp at bsdimp.com
Mon Jan 15 15:52:57 UTC 2018


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


More information about the freebsd-current mailing list