Given that the numbers are relatively small (~ -1 to ~ 1) and are floats and randomly generated, can you get 'floating point invalid operation' by adding too many of them? I am asking because that's what apparently happens in my program right now and very rarely too. Also, how does one disable (or avoid) this exception?
Just in case, my compiler is gcc (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 5.1.0.
EDIT As requested I am providing the code. However, the addition of floats causing the error is only my conjecture, that's why I came here, to find out if that could be my problem. If I run code below, is it reasonable that I can get the error?
#include <iostream>
int main()
{
float sum = 0, add = 0;
while (true)
{
add = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
if (rand() % 2) add *= -1;
sum += add;
}
}
EDIT 2: I don't get the error with the code above, I just need to know if it could happen.