[reporter="jvs", created="Mon, 23 Jan 2006 14:10:50 -0500 (GMT-05:00)"]
Case
when x < -5 then x * 2
When x < 0 then x + 10
When x < 10 when sqrt(x) + x * 2
Else sqrt(x)
End
For a negative number, we want to make sure not to evaluate sqrt(x). But the Java calc codegen currently spits out all the possible expressions needed first, and then uses a compound if/elseif/else structure to choose the right one.
We should make sure that both the predicates (x < 10) and the return values (x + 10) are only computed if all previous branches have been skipped.
[reporter="jvs", created="Mon, 23 Jan 2006 14:10:50 -0500 (GMT-05:00)"] Case
when x < -5 then x * 2
When x < 0 then x + 10
When x < 10 when sqrt(x) + x * 2
Else sqrt(x)
End
For a negative number, we want to make sure not to evaluate sqrt(x). But the Java calc codegen currently spits out all the possible expressions needed first, and then uses a compound if/elseif/else structure to choose the right one.
We should make sure that both the predicates (x < 10) and the return values (x + 10) are only computed if all previous branches have been skipped.