Software Archive
Read-only legacy content
17061 Discussions

CASE construct, but with reals

Intel_C_Intel
Employee
597 Views
Apparently I can't use a REAL variable as the case expression in a CASE consruct. Is there any similar construct in which I can do effectively the same thing using a REAL, or am I relegated to a series of IF ... THENs?
0 Kudos
2 Replies
Steven_L_Intel1
Employee
597 Views
Nope - can't use REALs. Keep in mind that comparing REALs for equality is often a source of trouble, as sometimes a computed result isn't exactly the decimal value you think it is. Depending on what your values are, perhaps you could convert the value to integer and CASE on that?

Steve
0 Kudos
Intel_C_Intel
Employee
597 Views
Thanks, anyway. Yes, I am familiar with the hazards of comparing reals.

Now I just have to decide which is uglier, the IF..THENs, or the conversion to an INTEGER case expression.
0 Kudos
Reply