TurboC v2.0 format problem

haskins at s.cs.uiuc.edu haskins at s.cs.uiuc.edu
Thu Jun 15 03:24:00 AEST 1989


I have a printf formatting problem with TurboC v2.0: when I do this with the
Huge model and the Tiny model, I get the results shown, w/ and w/o debugging
info.

I tried it with UNIX cc to make sure it wasn't me, and it comes out right.

Results of printf with format %7.3f:

a =   0.01
     ^^^^^   won't give me another trailing 0
b =  0.011
c =  0.100

/* the program testing the printf function */

#include <stdio.h>

main()
{
	float		a,b,c;

	a = 0.01;
	b = 0.011;
	c = 0.1;

	printf("a =%7.3f\n",a);
	printf("b =%7.3f\n",b);
	printf("c =%7.3f\n",c);
}

With various combinations of code, the problem appears and disappears.
Ordinarily this wouldn't be so horrible, but I'm working on a program that
puts values in a table and this doesn't look so hot.  And no, I don't have
Compu$erve access if it's been mentioned there.

Thanks in advance.
----------------------------------------------------------
Lloyd Haskins -- haskins at s.cs.uiuc.edu



More information about the Comp.lang.c mailing list