08-08-2019 03:43 AM
Hi i must use formula node to compute bit operation ,but when expression like c=a|b,when b is > 0x7fffffff ,the result is 0,but int16 is right,why? tested in labview 2017(32) Chinese Simplified,and labview 2019 (32) Chinese Simplified in win7 .
Solved! Go to Solution.
08-08-2019 04:58 AM
Probably a small inconsistency in the formula node where an int16 is internally extended to the full 32 bit register size anyways before doing the operators. For the int32 you basically have an overflow as the OR operator is done in the signed int32 space and then truncated when converted to the unsigned uInt32 space.
The formula node looks and smells like C but it isn't. It is only a subset of C and does generally work like C but isn't guaranteed to be exact C semantics. There are also syntactical differences to C such as the exponent operator.
08-08-2019 09:50 AM
A U32 or I32 is 4 bytes, or in hex written as 8 hex numbers, in your text you're using 9. The code looks ok, but you're doing an operation between a I32 and a U32, so i assume there's a conversion going on. 7fff ffff is the biggest positive number a I32 can have, anything 'bigger' and it turns into a negative number. All 'f's (I32) is -1 if memory serves.
/Y
08-09-2019 12:04 PM
I think Mr. Rolfk's suggestion may be correct. This question is related to the word length of the internal conversion. I tried it again with I32 and U32, but the result is also incorrect. The following picture is the result of my experiment and the solution to the operation. Currently, I don't know if the same result is obtained in labview (64).
08-09-2019 12:05 PM