Thread overview
[Issue 17160] Apparently faulty behavior comparing enum members using `is`
Feb 08, 2017
Sophie
Dec 12, 2019
Basile-z
Mar 21, 2020
Basile-z
Nov 08, 2020
Walter Bright
February 08, 2017
https://issues.dlang.org/show_bug.cgi?id=17160

--- Comment #1 from Sophie <meapineapple@gmail.com> ---
This issue seems not to occur when using `enum Enum: real` instead of double.

>From IRC:

<skl> hmm it does a byte comparison but they differ, one is 00D0CC... the other
is CDCCCCCC...
<adam_d_ruppe> i am guessing that the enum treats it more like a literal than
the variable does so it gets imprecise passed to functions
<skl> it stores the literial enum value as a real 80-bit floating point number
<skl> but it looks like it passes a double into the function

--
February 08, 2017
https://issues.dlang.org/show_bug.cgi?id=17160

jiki@red.email.ne.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |jiki@red.email.ne.jp

--- Comment #2 from jiki@red.email.ne.jp ---
This seems to work without the parameter attr 'in'.

test(Enum a)

--
December 12, 2019
https://issues.dlang.org/show_bug.cgi?id=17160

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |performance
                 CC|                            |b2.temp@gmx.com
                 OS|Windows                     |All

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
compiler explorer shows clearly that for (in Enum) a real (80 bits) comparison
occurs while for (Enum) a more correct (and faster) 64 bits.

https://godbolt.org/z/W5PYMn

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=17160

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
November 08, 2020
https://issues.dlang.org/show_bug.cgi?id=17160

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|---                         |WONTFIX

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
0.1 cannot be represented exactly with floating point types. In particular, taking an 80 bit value and comparing it with a rounded 64 bit value will not come out as identical.

Rounding and inexact floating point operations are just something we have to deal with.

--