View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000822 | LDMud | LPC Language | public | 2013-07-13 00:31 | 2014-02-23 21:15 |
| Reporter | bubbs | Assigned To | zesstra | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | won't fix | ||
| Platform | 3.2.17 | ||||
| Summary | 0000822: 0.0 == !0.0 | ||||
| Description | On 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 Reproduce | int test() { return 0.0 == !0.0; } | ||||
| Tags | No tags attached. | ||||
| External Data (URL) | |||||
|
|
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. |
|
|
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. |
|
|
Gnomi and me agree with Invisible, so we will keep it as it is. |
| 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 |