04-14-2011 03:34 AM
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
Solved! Go to Solution.
04-14-2011 03:39 AM
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.
04-14-2011 03:45 AM
Thanks a lot
03-27-2015 10:34 AM
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 ?
03-27-2015 11:35 AM