posted 19 years ago
Hi,
I came across some unexpected behaviour today, regarding double,float and double,double multiplications. I get the values 240000.0 and 239999.99463558197 respectively when the program below is run.
I expected both results to be the same since the float b2, was being cast to a double which would mean that the same underlying calculation would be performed. But I just found out (right now!) that the widening conversion to double of b2 produces 0.07999999821186066 and not 0.08 as I expected. I do not understand why this should be as no calulation is being performed which would introduce the usual float/double error, just a simple widening conversion.
Oh well, I guess I'll stick to doubles for now...