Bug 361 – Compile-time floating-point calculations are sometimes inconsistent

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-09-21T18:46:00Z
Last change time
2014-02-15T13:22:14Z
Assigned to
bugzilla
Creator
digitalmars-com

Comments

Comment #0 by digitalmars-com — 2006-09-21T18:46:00Z
The following code should print false before it exits. import std.stdio; void main() { const float STEP_SIZE = 0.2f; float j = 0.0f; while (j <= ( 1.0f / STEP_SIZE)) { j += 1.0f; writefln(j <= ( 1.0f / STEP_SIZE)); } } This problem does not occur when: 1. the code is optimized 2. STEP_SIZE is not a const 3. STEP_SIZE is a real
Comment #1 by digitalmars-com — 2006-09-21T18:46:52Z
Accidental reload by browser. *** This bug has been marked as a duplicate of 360 ***