Generally, yes. Fantastic, I know!
Although there are different things from programming language to programming language. I don't know specifically about Java, but with Visual Basic .Net, the Boolean system is slightly different; like TI-Basic, if the result of an If statement is NOT zero, then it is accepted as being true. However, when it makes evaluations, -1 is returned when the statement is true. Have a look at this table:
Expression |
Value Returned |
Boolean Translation |
2+2 |
4 |
True |
2=0 |
0 |
False |
2=2 |
-1 |
True |
So here is a side-by-side comparison how you would do a Piecewise Expressions in two different programming languages:
TI-Basic |
Visual Basic .Net |
:A(A≥0)-A(A<0→B |
B = A(A<0)-A(A≥0) |
How fantastic is that?
Aren't Piecewise expressions just the best? And they are so fun to create too!
Cheers ~ James Kanjo