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

2018-01-15 Thread Yuri Pankov
On Mon, Jan 15, 2018 at 08:38:15PM +0300, Mehmet Erol Sanliturk: On Mon, Jan 15, 2018 at 5:38 PM, Yuri Pankov > wrote: Hi, Looking at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

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

2018-01-15 Thread Steve Kargl
On Mon, Jan 15, 2018 at 08:38:15PM +0300, Mehmet Erol Sanliturk wrote: > > When you perform floating point computations , it may be useful > to ... read David Goldberg's paper, "What Every Computer Scientist Should Know about Floating-Point Arithmetic." http://www.validlab.com/ -- Steve

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

2018-01-15 Thread Mehmet Erol Sanliturk
On Mon, Jan 15, 2018 at 5:38 PM, Yuri Pankov wrote: > Hi, > > Looking at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149, I > noticed that it isn't a seq(1) problem per se, rather for() and while() > loops behaving inconsistently while using floating point, i.e.: > >

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

2018-01-15 Thread Yuri Pankov
On Mon, Jan 15, 2018 at 02:54:59PM +, David Chisnall: On 15 Jan 2018, at 14:49, Hans Petter Selasky wrote: The "seq" utility should use two 64-bit integers to represent the 10-base decimal number instead of float/double. And then you need to step this pair of integers.

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

2018-01-15 Thread Warner Losh
On Mon, Jan 15, 2018 at 7:38 AM, Yuri Pankov 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

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

2018-01-15 Thread David Chisnall
On 15 Jan 2018, at 14:49, Hans Petter Selasky wrote: > > The "seq" utility should use two 64-bit integers to represent the 10-base > decimal number instead of float/double. And then you need to step this pair > of integers. As the saying goes: > Sometimes, people think 'I

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

2018-01-15 Thread Hans Petter Selasky
Hi, The "seq" utility should use two 64-bit integers to represent the 10-base decimal number instead of float/double. And then you need to step this pair of integers. --HPS ___ freebsd-current@freebsd.org mailing list

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

2018-01-15 Thread Hans Petter Selasky
On 01/15/18 15:38, Yuri Pankov wrote: Hi, Looking at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149, I noticed that it isn't a seq(1) problem per se, rather for() and while() loops behaving inconsistently while using floating point, i.e.:     double i;     for (i = 1; i

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

2018-01-15 Thread Yuri Pankov
Hi, Looking at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149, I noticed that it isn't a seq(1) problem per se, rather for() and while() loops behaving inconsistently while using floating point, i.e.: double i; for (i = 1; i <= 2.00; i += 0.1)