Mail Archives: djgpp/1997/03/04/23:26:33
> int main()
> {
> float a;
> a=4.00/5.00;
> printf("float = %.12f\n",a);
> return(1);
> }
> Ans = 0.800000011921
> The correct answer should be 0.800000000000 but he gets these extroneous
> numbers tacked on the end???
just for the record, I just tried this on the sparc Sun here and got the
same answer, so its a fault of FP precision (IEEE)... :) The problem is
he is using floats which don't have 12 decimal places of precision. If
he wants more precision, he should use doubles - then he will get the
right answer... (I just tried... :)
Leathal.
- Raw text -