求助浮点数上溢下溢问题
关于C primer plus 第三章编程练习第一题的疑问。
整数的溢出弄明白了,但是对于浮点数的,还是有些不明白,麻烦有明白的讲一下。

浮点数倒也正常显示啊。。。我用的支持C99的编译器。。
如果把代码改成这样
结果是
上溢是正常的,下溢又不正常。。。这是什么原因呢?表示很疑惑。。
整数的溢出弄明白了,但是对于浮点数的,还是有些不明白,麻烦有明白的讲一下。
#include<stdio.h>
int main(void)
{
int a = 2147483647;
float b = 3.40E+38;
float c = 10.0E-37f;
printf("the value of a is %d,the overflow of int is %d,the other is %d\n",a,a+1,a+2);
printf("the maxiest value of float is %e,the overflow is %e\n",b,b*10.0f);
printf("the minius value of float is %e,the overflow is %e\n",c,c/100);
return 0;
}
,结果是
浮点数倒也正常显示啊。。。我用的支持C99的编译器。。
如果把代码改成这样
#include<stdio.h>
int main(void)
{
int a = 2147483647;
float b = 3.40E+38*100.0f;
float c = 10.0E-37f/100;
printf("the value of a is %d,the overflow of int is %d,the other is %d\n",a,a+1,a+2);
printf("the maxiest value of float is %e,the overflow is %e\n",b,b*10.0f);
printf("the minius value of float is %e,the overflow is %e\n",c,c/100);
return 0;
}结果是

上溢是正常的,下溢又不正常。。。这是什么原因呢?表示很疑惑。。
...全文
相关推荐
Matlab实现算术编码(arithmetic coding)演示下溢问题
Matlab代码的输入为一个字符串,输出为range,bits,high_value和low_value。算术编码(arithmetic coding)演示下溢问题
计算机组成原理:浮点数表示及运算 .ppt
计算机组成原理:浮点数表示及运算 .ppt
IEEE_754关于浮点数的规定★.ppt
IEEE_754关于浮点数的规定★.ppt
计算机组成原理:浮点数表示及运算.ppt
计算机组成原理:浮点数表示及运算.ppt
计算机精度问题(Double)
NULL 博文链接:https://jun1986.iteye.com/blog/1136403


