Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

CASE construct, but with reals

Intel_C_Intel
Employee
870 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
870 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
870 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