View Issue Details

IDProjectCategoryView StatusLast Update
0000822LDMudLPC Languagepublic2014-02-23 21:15
Reporterbubbs Assigned Tozesstra  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionwon't fix 
Platform3.2.17 
Summary0000822: 0.0 == !0.0
DescriptionOn an admittedly old 3.2.17 driver, 0.0 == !0.0 returns non-zero.

Is this fixed in later versions? Apologies I'm not able to test this myself.
Steps To Reproduceint test() { return 0.0 == !0.0; }
TagsNo tags attached.
External Data (URL)

Activities

zesstra

2013-07-14 22:09

administrator   ~0002187

Well, first my comment, why the result is the way it is:
!0.0 evaluates to 0 (int). In general, !x always evaluates to 0 if x is not 0 (int).
The comparison is then 0.0 == 0. The 0 is converted to a double first which is then tested for equality with 0.0, which results in 1.
Or to put it differently: in C the comparison is 0.0 == (double)0.

I agree this unexpected at first. However, I am not sure if there is a better way, unless we change the tests to equality that ints and floats can never be equal.

invisible

2013-07-15 17:33

reporter   ~0002190

Using logical operators on float numbers is always tricky. You can't rely on 0.0 really being == (int)0 - sometimes it is, mostly it isn't. Thus the result of 0.0 == !0.0 is inherently unpredictable.

zesstra

2014-02-23 21:15

administrator   ~0002227

Gnomi and me agree with Invisible, so we will keep it as it is.

Issue History

Date Modified Username Field Change
2013-07-13 00:31 bubbs New Issue
2013-07-14 22:09 zesstra Note Added: 0002187
2013-07-15 17:33 invisible Note Added: 0002190
2014-02-23 21:15 zesstra Note Added: 0002227
2014-02-23 21:15 zesstra Status new => closed
2014-02-23 21:15 zesstra Assigned To => zesstra
2014-02-23 21:15 zesstra Resolution open => won't fix