02-15-2017 09:57 AM
Hello everyone.
Probably it's a trivial problem but I can't work it out.
I need to create a case structure with 3 cases:
First case if x < c
Second case if x = c
Third case if x > c
where both x and c are variables. I can't believe the only way is nested case structure. I know selector labels can contain a range like 0...4, but what if instead of 4 I have a variable (c)??
Any help is really appreciated.
Matteo
Solved! Go to Solution.
02-15-2017 10:13 AM - edited 02-15-2017 10:13 AM
Subtract your numbers. Then in the numeric palette is a function called "Sign". It will return -1, 0, or 1 based on the sign of the value passed into it.
02-15-2017 10:22 AM
Yes,that was really easy. I had not seen Sign function. Thank you very much.
02-15-2017 11:02 AM
Be careful. That may not work for all cases. There is always a problem in comparing DBLs to zero or to each other (i.e., x=0 or x=y). I attached a snippet as an example.
If you type in the values of 0.1 directly into the controls, the result of the "Sign" is as expected.
If the Values are computed from other control values you get an unexpected results
I SUBTRACTED two DBLs and the results is ~0.1
I DIVIDED two DBLs and the results is also ~0.1
However 0.1 - 0.1 <> 0 in this case. The results of the "Sign" function is 1!!
02-15-2017 11:16 AM
You're right. In my case I subtract integers so it's ok. Thank you for the clarifications anyway.