FLOAT 的有效位數
(高顯忠, sjgau4311@gmail.com, 2011-04-18 06:21)
1樓
#include <cstdlib>
#include <iostream>
#include <math.h>
// ----------------------------------------------
using namespace std;
// ----------------------------------------------
int main(int argc, char *argv[])
{
float x, y;
x= 4.0*atan(1.0);// x= 3.1415926
y= x + 1.0;
printf("\n x= %.22f, \n y= %.22f \n", x, y);
system("PAUSE");
// ------------------------------------------
while (y > x) {
x*= 1.00001;
y= x + 1.0;
}
printf("\n *** exit the loop! \n");
printf("\n x= %.22f, \n y= %.22f \n", x, y);
system("PAUSE");
// ------------------------------------------
y= (log(x))/(log(2.0));
printf("\n x= %.22f, \n y= %.22f \n", x, y);
system("PAUSE");
return EXIT_SUCCESS;
}// end of main()