From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formula node uInt32 overflow

I'm having a weird behaviour in formula node. The overflow of unsigned integer operations simply doesn't match the results of standard LabVIEW blocks as shown in the attached picture.

 

How can I deal with this problem? I need the behaviour of the block diagram. I could not do a right logical shift in unsigned integers in block diagram, so I'm using formula node (I could not figure out how to do it because I can't negate a unsigned value).

 

I'm using LV2012SP1. Were there any changes in this behaviour in newer versions?

 

Thank you.

 

Formula node problem

0 Kudos
Message 1 of 5
(3,521 Views)

I don't know. I get 0 for an answer too  for  x*y.

0 Kudos
Message 2 of 5
(3,508 Views)

Exactly what are you trying to do? Logical Shift, Rotate, and Rotate Right with Carry are all polymorphic functions. They will accept any integer type including U32 and U64. The output changes to match the input type. The y inputs will accept any 8-, 16-, or 32-bit integers. They coerce 64-bit integers. 

 

Multiplication is not the same as logical shift.

 

Lynn

0 Kudos
Message 3 of 5
(3,482 Views)

Yes it does appear that the overflow behavior is different between the formula node and the primitives.  I would expect a detail like that to be documented, but to be honest I would be more surprised if it were documented than I am that it was not....

 

By definition, you will not be shifting by more than 32 bits (at least not while expecting a non-zero result), so it seems like you would be safe coercing to I32 and negating to get a right shift, coerce to I64 if you are paranoid.

0 Kudos
Message 4 of 5
(3,463 Views)

I found a problem in hexadecimal and octal numeric representations of the formula node. The picture illustrates the issue. Three variables are assigned with the same value but outputs different results.

 

The hex and octal representations only work for half range of the 32 bits unsigned integer. When the value assigned gets beyond this limit the variable receives zero. This doesn't happen with a decimal value neither with 8 bits variables. Seems the problem doesn't only happen with overflow operations.

 

 

 

 

hexa and octal issues

0 Kudos
Message 5 of 5
(3,425 Views)