rational number's arithmetic operation malfunction

"1 + (B/A)" is different from "(A+B) / A"

example,

A = 0.0048828125*0.0002953;
B = 29.92126;

following result :

(A+B) / A : Serial.print = 0.0000001192
1 + (B/A) : Serial.print = 0.0000000000

it is not casting problem.

total source code :


void setup() {
Serial.begin(9600);
}

void loop() {
double A = 0.0048828125*0.0002953;
double B = 29.92126;

Serial.println( (double)( (double)A + (double)B) / (double)B , 10 );
Serial.println( (double)((double)1)+(double)((double)A / (double)B),10 );

while(1);
}


"float" is same, too.

i am very confuse....

what's problem for me?

what's problem for me?

Your expectations of 32 bit floating point arithmetic are too high?

"1 + (B/A)" is different from "(A+B) / A"

That's not what the (badly posted) code does.

Thank you.

you are right.

mentisa is overflow..

both float and double are 4bytes.

following result :
(A+B) / A : Serial.print = 0.0000001192
1 + (B/A) : Serial.print = 0.0000000000

Strange, I would expect

1.0000001192
1.0000000000

made me think of the saying "1 + 1 = 3 for very large values of 1"