View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000780 | LDMud 3.6 | General | public | 2011-02-19 21:51 | 2022-01-09 20:31 |
Reporter | sinnvoll | Assigned To | Gnomi | ||
Priority | normal | Severity | tweak | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Fixed in Version | 3.6.5 | ||||
Summary | 0000780: Seltsame float 0, | ||||
Description | zlpc return 0.; Got=0 zlpc return !0.; Got=0 zlpc return 0.==0 Got=1 | ||||
Tags | No tags attached. | ||||
|
Ok, concerning example 1: zlpc in UNItopia uses to_string() for output of floats. to_string() uses "%g" in sprintf() to print T_FLOAT. And the sprintf manpage states: "a decimal point appears only if it is followed by at least one digit." I think, we have to include that comment as well in our manpage of to_string - or change it in a way to print the same as our sprintf("%d")... Note: Our %d in sprintf does not behave the same: 0.0 is printed as "0.0". Example 2: Basically, 0.0 is not equal 0, so !0. == 0 is in general justified. It just looks contradictory to Example 3. Example 3: The F_EQ (==) operator converts T_NUMBER into double before comparing them with == with the T_FLOAT argument, therefore the comparison returns true... |
|
Sin suggested to document the special meaning of 0 (e.g. assignable to every type, initialization value for any type, but despite this always an integer) and its implications. |
|
Hmm, I think example 2 should return 1. !x should be the same as x == 0. |
|
Although we don't like the current behavior, we hesitate to change it, because one cannot detect where it will break existing code. Therefore we decided to issue warnings, whenever floating point numbers are used in a boolean context and pragma warn_deprecated is in effect. |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-02-19 21:51 | sinnvoll | New Issue | |
2011-02-19 22:28 | zesstra | Note Added: 0002004 | |
2011-02-19 22:56 | zesstra | Note Added: 0002005 | |
2011-02-21 23:10 | Gnomi | Note Added: 0002022 | |
2021-04-16 19:48 | zesstra | Project | LDMud 3.5 => LDMud 3.6 |
2021-04-16 19:48 | zesstra | Category | LPC Language => General |
2021-04-16 22:07 | Gnomi | Note Added: 0002614 | |
2021-06-04 09:28 | Gnomi | Assigned To | => Gnomi |
2021-06-04 09:28 | Gnomi | Status | new => assigned |
2022-01-09 20:31 | Gnomi | Status | assigned => resolved |
2022-01-09 20:31 | Gnomi | Resolution | open => fixed |
2022-01-09 20:31 | Gnomi | Fixed in Version | => 3.6.5 |