LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Summing values in array of boolean array of ones and zeros

Solved!
Go to solution

Hi.

 

I have a boolean array which I have converted to ones and zeros. I simply want to sum all the elements in this array (in other words giving the number of ones in the array). I used the add elements function but I get a negative value. I checked there weren't any values other than one and zero (I know there shouldn't be) using the max and min function. I'm not sure how a negative value has been calculated - any ideas.

 

Thanks in advance

0 Kudos
Message 1 of 5
(5,193 Views)
Solution
Accepted by topic author jnaumann1

Before adding the elements, convert the array to I32 or I64. The output of the Add primitive is the same type as the input, and if the input is an I16, then you can't have a value bigger than 32,767 or the value will wrap around (which is what happened in your case.


___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(5,187 Views)

Thanks a lot

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

Hi 

 

I try to do the same thing. just count the number of ones and I did as you said but it is not working. there is a mistake in somewhere. I try to add the array or in other words find the number of ones. add the ones. :womanvery-happy: 

Could you please navigate me to what to do ?

 

0 Kudos
Message 4 of 5
(4,438 Views)

Hi fate,

 

duplicate post, continue here!

 

Don't hijack old threads!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(4,418 Views)