Inherent imprecision of floating point variables
Matthew Farwell
dylan at ibmpcug.co.uk
Thu Jun 28 00:16:46 AEST 1990
In article <44436 at ism780c.isc.com> marv at ism780.UUCP (Marvin Rubenstein) writes:
>The problem has nothing to do with C or the precision of the machine's
>floating point unit. It has to do with the precision of the ASCII to float
>and float to ASCII conversion routines. This problem was addressed at the
>SIGPLAN '90 conference on Program Language Design and Implementation. Two
>papers appear in the proceedings:
Consider the code segment:-
main()
{
float f;
f = 0.0;
while (1) {
if (f == 10.0) break;
printf("%f\n", f);
f += 0.1;
}
printf("Stopped\n");
}
If its all to do with conversion routines, why doesn't this stop when f
reaches 10?
Dylan.
--
Matthew J Farwell | Email: dylan at ibmpcug.co.uk
The IBM PC User Group, PO Box 360,| dylan%ibmpcug.CO.UK at ukc
Harrow HA1 4LQ England | ...!uunet!ukc!ibmpcug.co.uk!dylan
Phone: +44 81-863-1191 | Sun? Don't they make coffee machines?
More information about the Comp.lang.c
mailing list