Pike v7.6 release 24 running Hilfe v3.5 (Incremental Pike Frontend)
atan(tan(1.0));
(1) Result: 1.000000
atan(tan(Math.pi/2));
(2) Result: -1.570796
tan(Math.pi/2);
(3) Result: -22877332.000000
Wazzaaa?
What is the right side of 0.0 then?
lim tan(x) = -Inf x->pi/2+
lim tan(x) = +Inf x->pi/2-
In this case, I think Nilsson is expecting to approach Pi/2 from 0, which means that Math.inf would be the correct result.
What seems strange to me is that Math.pi/2!=it's numerical value.
In this case, I think Nilsson is expecting to approach Pi/2 from 0, which means that Math.inf would be the correct result.
How is Pike supposed to know that, if he supplies a value slightly larger than Pi/2?
What seems strange to me is that Math.pi/2!=it's numerical value.
You are probably confused by the fact that the decimal representation of the float as printed by hilfe does not exactly capture the internal binary representation.
| orchid% pike | Pike v7.7 release 11 running Hilfe v3.5 (Incremental Pike Frontend) | > tan(Math.pi/2); | Impossible tangent.
32-bit floats doesn't have enough precision.
pike-devel@lists.lysator.liu.se