RE: [Dev-C++] Problems using float variables with DevC v4
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-05-18 04:30:46
|
The first printf() produces to me: 4.000000e+000 3.141593e+000 which is what is expected i guess. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of aloysiojr01 > Sent: Friday, May 17, 2002 5:06 PM > To: dev...@li... > Subject: [Dev-C++] Problems using float variables with DevC v4 > > > Hello guys, > > I have problems using float variables using DevC version > 4. I don't get correct answers. Please see the code: > > #include <stdio.h> > #include <stdlib.h> > #include <math.h> > #define pi 3.1415927 > #define precisao 0.01 > > int main(int argc, char *argv[]) > { > float valor = 4.0; > int numerador = 4; > int denominador = 3; > int sinal = -1; > > printf("%e\t%e\t",valor,pi); > > do > { > valor+= sinal*(numerador/denominador); > sinal*=-1; > denominador+=2; > printf("%d\t%d\n",denominador,sinal); > }while(fabs((valor-pi))>precisao); > > printf("%4.2f\n",valor); > system("pause"); > > > return 0; > } > > At the first printf i get wrong values. Am i forgetting > sth? Is there any compiler option to be set? > > Please help me. > > Best Regards, > > Aloysio Souza. |