Bug 12831 – assert incorrectly fails on to!float conversion

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2014-06-01T01:57:00Z
Last change time
2014-06-01T13:23:38Z
Assigned to
nobody
Creator
mk

Comments

Comment #0 by mk — 2014-06-01T01:57:22Z
import std.conv; void main() { float a = 1.234f; float b = to!float("1.234"); assert (a == b); assert (a == to!float("1.234")); //fails } DMD32 D Compiler v2.066-devel-38c5c36 Works in gdc. Also works with real.
Comment #1 by mk — 2014-06-01T02:12:12Z
import std.conv; void main() { float a = 1.234f; real b = to!float("1.234"); assert (a == b); //fails } Maybe I'm missing something about fpu arithmetics, this fails too, but again works in gdc.
Comment #2 by mk — 2014-06-01T13:23:38Z
marking INVALID as floating point numbers shouldn't be compared directly for equality (machine and platform dependent).