From owner-freebsd-current@freebsd.org Mon Jan 15 14:39:23 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68B2CEA6C65 for ; Mon, 15 Jan 2018 14:39:23 +0000 (UTC) (envelope-from yuripv@icloud.com) Received: from pv33p00im-asmtp001.mac.com (pv33p00im-asmtp001.me.com [17.142.194.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B78778272 for ; Mon, 15 Jan 2018 14:39:23 +0000 (UTC) (envelope-from yuripv@icloud.com) Received: from process-dkim-sign-daemon.pv33p00im-asmtp001.me.com by pv33p00im-asmtp001.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0P2L00400OAG3T00@pv33p00im-asmtp001.me.com> for freebsd-current@freebsd.org; Mon, 15 Jan 2018 14:38:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=04042017; t=1516027138; bh=sFjLpCN0tHmgydKZ7aZMyXU3J2s59nxZGwz3Gx0dU2Y=; h=To:From:Subject:Message-id:Date:MIME-version:Content-type; b=dwdIL8X6T7BnS0CLehhxgqWQWCVQqzeyK8LOl3X4JCA0rDU4GPxTRRR+KTCKnvGCr spnxkzGeWp3wZ1Nt9g+9zCcXrOGg/jwifRp95VvkFuN2cIwmih74cK1B0BPzASDGVC tsJWxhXN4V5FdJUhaL5aeVf5Tv+SCEVOB0bXfI/TAAIrFbuMShF+utH4gFFSPrccaN umrF1vCOWOF87QYeaILkFRXoIqgV4D9AOCnEK0rfZa4n3j8SahqqwPtALA/07OWvCd RA5ro0vBEg6a2SPBrp8ledLzVULy2JH4Kab1RHJEnVSJJ62O/vw6LHsRcw5S4eWXjn VCNvJnQNViRuA== Received: from icloud.com ([127.0.0.1]) by pv33p00im-asmtp001.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0P2L0087ZQ0U3T00@pv33p00im-asmtp001.me.com> for freebsd-current@freebsd.org; Mon, 15 Jan 2018 14:38:57 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-15_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1801150209 To: freebsd-current From: Yuri Pankov Subject: inconsistent for() and while() behavior when using floating point Message-id: <6c423dbf-cd85-3c93-41e4-3362c06dfbb7@icloud.com> Date: Mon, 15 Jan 2018 17:38:54 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed Content-language: en-US Content-transfer-encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 14:39:23 -0000 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?