Re:Things I will tell my kids if they become entrepreneurs [...
by mipmap04 on Monday October 31, 2016 @08:39AM
(#12836142)
He's saying the left hand side of the equation. The order of the items on the right hand side does not matter.
[ Parent
| on HN ]
Re:Things I will tell my kids if they become entrepreneurs [...
by mangeletti on Monday October 31, 2016 @08:42AM
(#12836171)
Can an interpreter shirt curcuit a multiplication if the left side is 0? In Python, for instance, is the following:
a * b * c * d
computed like this?: ((a * b) * c) * d
Or is it computed like this?: a * ((b * c) * d)
If the former is the case, then the chongli optimization could help, right?
Re:Things I will tell my kids if they become entrepreneurs [...
by palunon on Monday October 31, 2016 @09:20AM
(#12836424)
If you have IEEE compliant floats, you can't, because the right side may result in Infinity, making the complete product NaN.
Re:Things I will tell my kids if they become entrepreneurs [...
by mangeletti on Monday October 31, 2016 @10:02AM
(#12836744)
Interesting.
We're talking integers here, though (re: Python).
Re:Things I will tell my kids if they become entrepreneurs [...
by nayuki on Monday October 31, 2016 @01:16PM
(#12838781)
No, an interpreter cannot short-circuit a zero multiplication. This is because the expressions could be functions that raise exceptions.
e.g. 0 * (0/0)
e.g. f() * raise_some_exception()
Re:Things I will tell my kids if they become entrepreneurs [...
by mangeletti on Monday October 31, 2016 @01:46PM
(#12839123)
Ah, of course. In hindsight, I now feel pretty silly even asking that.
Re:Things I will tell my kids if they become entrepreneurs [...
by chrisseaton on Monday October 31, 2016 @09:32AM
(#12836508)
Short circuiting means branching, which is likely to be slower than running operators that you know to result is zero.