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)
                printf("%g\n", i);

would produce:

        1
        ...
        1.9

but:

        double i;

        for (i = 1; i <= 2; i += 0.2)
                printf("%g\n", i);

would correctly end with 2:

        1
        ...
        2

$ cc -v
FreeBSD clang version 6.0.0 (branches/release_60 321788) (based on LLVM 6.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin

though gcc 4.4.4 on illumos behaves the same.

Is this a known problem with loops and floating point numbers?
_______________________________________________
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to