LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Bart_Boshuizen

select coersion type

Status: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.

When comparing a U32 with an I32, e.g. with Less?, it will compare U32's. The result is that an I32 of -1 is considered larger than a U32 of 2. Of course converting the U32 to an I32 would solve this problem. My idea is that LabVIEW allows me to choose the coersion type on the Less? function (and the likes).

 

less with wrong coersion.png

Bart Boshuizen,
www.morechemistry.com
2 Comments
peos
Member

Relying on coersion can be a programmers trap. If your int value usually is positive, then the program works fine. But when it becomes negative, your program might fail unnoticed. My advise is to see these red dots as warning signs and avoid them. If you need the full range of the U32 number, convert both values to int-64 before the comparison. 

 

If it was possible to disable coersion and getting an error instead, I would choose that option.

Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.