Bug 12882 – Parser ^^ operator results in invalid result
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-09T15:02:00Z
Last change time
2014-06-10T08:53:06Z
Assigned to
nobody
Creator
temtaime
Comments
Comment #0 by temtaime — 2014-06-09T15:02:16Z
import std.stdio;
void main() {
real a = -2;
real b = -2.1;
(a ^^ b).writeln;
(-2 ^^ -2.1).writeln;
}
Output:
-nan
-0.233258
Should be nan in both cases.
Comment #1 by safety0ff.bugz — 2014-06-09T17:54:43Z
N.B.: ^^ has higher precedence than unary minus:
import std.stdio;
void main() {
real a = -2;
real b = -2.1;
(a ^^ b).writeln;
((-2) ^^ -2.1).writeln;
}
This gives:
-nan
nan
The sign of nan has no meaning.
Comment #2 by temtaime — 2014-06-09T17:57:55Z
This makes no sense.
Why priority of ^^ is higher ?
Comment #3 by safety0ff.bugz — 2014-06-09T18:07:15Z