problem with arithmetic

I hope there is something obvious I’m missing:

I’m summing the point-wise product of two arrays, A and B of equal length

float subtotal = 0;
for(int i=0; i<length(A);i++){
subtotal += A_B;_
_
}*_
Whats happening is that subtotal ends up being zero (yet somehow not == 0), although every element of both A and B is greater or equal 0.
Let B be kept constant, then for some arrays A, the sum is as it should be, but for others, it shows this bizarre behavior where subtotal_i is as it should be up until a certain point j, after which subtotal_i>j is zero (but not == 0!) AND what’s more crazy is that a modified code including a subroutine which checks if subtotal_i+1 is ever less than subtotal_i always returns false!
So maybe I’m delusional and it’s just the way that the Serial.print(subtotal_i) is formatting the output when i try to debug it, except how is it possible that it prints “0.00” for subtotal_j+1 and some number n!=0 for subtotal_j without ever returning true for that subroutine? It’s not a formatting error - the problem is that when i try to calculate with subtotal later, it’s treated as zero when it clearly should not be zero. The same routine done in a sketch in processing works without problems. I chose not to include my source code because i think it would probably obfuscate the idea more than my rambling does.
My guess is something to do with precision. In particular, one array is essentially random numbers, but the other is a Gaussian distribution loaded into an array by evaluating a function of the form B = exp(-sq(i-a)/b). However, B = exp(-i) is one example of a function which doesn’t cause this strange behavior. Whats wrong with using the expression for a Gaussian curve???

You’ll need to post more (preferably all) of your code.

How are A and B declared?

You'll need to post all of your code. The snippet you post leaves a lot of questions. What type are A and B? How is length() defined?

I’m summing the point-wise product of two arrays, A and B of equal length

think the code should at least use some indexes as A and B are arrays

``````float subtotal = 0;
for(int i=0; i<length(A);i++){
subtotal += A[i]*B[i];
}
``````