# 精度 强制转换 浮点数

int main(){
char *a0="0.89";
char *a1="1.89";
char *a2="2.89";
char *a3="3.89";
char *a4="4.89";
char *a5="5.89";
char *a6="6.89";
char *a7="7.89";
char *a8="8.89";
char *a9="9.89";

long A0=atof(a0)*100;
long A1=atof(a1)*100;
long A2=atof(a2)*100;
long A3=atof(a3)*100;
long A4=atof(a4)*100;
long A5=atof(a5)*100;
long A6=atof(a6)*100;
long A7=atof(a7)*100;
long A8=atof(a8)*100;
long A9=atof(a9)*100;

printf("%.16lf\n",atof(a0));
printf("%.16lf\n",atof(a1));
printf("%.16lf\n",atof(a2));
printf("%.16lf\n",atof(a3));
printf("%.16lf\n",atof(a4));
printf("%.16lf\n",atof(a5));
printf("%.16lf\n",atof(a6));
printf("%.16lf\n",atof(a7));
printf("%.16lf\n",atof(a8));
printf("%.16lf\n",atof(a9));

printf("*******\n");

printf("%.16lf\n",atof(a0)*100);
printf("%.16lf\n",atof(a1)*100);
printf("%.16lf\n",atof(a2)*100);
printf("%.16lf\n",atof(a3)*100);
printf("%.16lf\n",atof(a4)*100);
printf("%.16lf\n",atof(a5)*100);
printf("%.16lf\n",atof(a6)*100);
printf("%.16lf\n",atof(a7)*100);
printf("%.16lf\n",atof(a8)*100);
printf("%.16lf\n",atof(a9)*100);

printf("*******\n");

printf("%ld\n",A0);
printf("%ld\n",A1);
printf("%ld\n",A2);
printf("%ld\n",A3);
printf("%ld\n",A4);
printf("%ld\n",A5);
printf("%ld\n",A6);
printf("%ld\n",A7);
printf("%ld\n",A8);
printf("%ld\n",A9);

}

0.8900000000000000
1.8899999999999999
2.8900000000000001
3.8900000000000001
4.8899999999999997
5.8899999999999997
6.8899999999999997
7.8899999999999997
8.8900000000000006
9.8900000000000006
*******
89.0000000000000000
189.0000000000000000
289.0000000000000000
389.0000000000000000
488.9999999999999432
589.0000000000000000
689.0000000000000000
789.0000000000000000
889.0000000000000000
989.0000000000000000
*******
89
189
289
389
488
589
689
789
889
989

3.89
4.89
5.89

1 11 52

111000111101011100001010001111010111000010100011110101110000

100位的表示

1110001111010111000010100011110101110000101000111101011100001010001111010111000010100011110101110000

3.89
11.111000111101011100001010001111010111000010100011110101110000
1.1111000111101011100001010001111010111000010100011110101110000*2^1

0

00000000001

1111000111101011100001010001111010111000010100011110

0000000000011111000111101011100001010001111010111000010100011110

4.89
1.00111000111101011100001010001111010111000010100011110101110000*2^2
0 00000000010 0011100011110101110000101000111101011100001010001111

5.89
1.01111000111101011100001010001111010111000010100011110101110000*2^2
0 00000000010 0111100011110101110000101000111101011100001010001111

3.8900000000000001
4.8899999999999997
5.8899999999999997

*100后，转为二进制，代表的值是：

389.0000000000000000
488.9999999999999432
589.0000000000000000

488.9999999999999432就是488

#### 浮点数强制转换为整型数据

2016-10-21 15:10:00

#### 浮点数强制转换为整数高效替代方法

2015-11-23 16:17:07

#### 浮点数的优缺点

2014-10-28 21:11:48

#### 在C++中将浮点数强制转换为整数，做了些什么——ftol注释

2017-03-05 00:40:31

#### 显式类型<em>转换</em>,类型<em>强制转换</em>为<em>浮点</em>型和整型

2018年05月08日 00:00

#### 测试浮点数和整型数之间的转换处理

2017-11-09 17:54:56

#### C语言中int到float的强制类型转换

2015-09-11 18:52:09

#### 如何提高浮点数变整数的精度

2016-10-21 16:21:12

#### 普通浮点数转半精度工具实现

2017-09-20 15:57:02