C program not adding float correctly
I have a method that looks like this: float * mutate(float* organism){ int i; float sign = 1; static float newOrg[INPUTS] = {0}; for (i = 0;i<INPUTS;i++){ if (rand() % 2 == 0) { sign = 1; } else { sign = -1; } float temp = (organism[i] + sign); printf("bf: %f af: %f diff: %f sign: %f sign2: %f temp: %f\n\n", organism[i], (organism[i] + sign), (organism[i] + sign)-organism[i], sign, sign+sign, temp); newOrg[i] = organism[i] + sign; } return newOrg; } When sign is not 0 the first two "%f" s are the same and the 3rd is 0, also putting the sum in a variable didn't help. This is baffling me! I can