我研究这个问题已经很久了,但我不明白这个问题的意思。
问题:
Write a program in any language to determine how your computer handles graceful
underflow.我理解溢出条件是这样的:如果一个整数可以存储一个最大值x,如果我们指定x+1的值,则x+1值将转换为整数能够容纳的最低值。我知道地下水流正好相反。
如何从高性能科学计算/线性代数的角度出发?
我读过这个链接,但是我认为它和我上面提到的相同的潜流/溢出的东西。优美的地下水流代表什么?
发布于 2014-11-07 05:50:05
好吧,根据此链接 @StoneBird发布的链接,这是非常有帮助的。在这里,我用c语言创建了一个程序,演示了相同的内容。
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
unsigned int s,e,m;
unsigned int* ptr;
float a,temp=0;
a=1;
float min=pow(2,-129);
while(a>min){
temp=a;
a=a/2;
}
printf("Value=%e\n",temp);
ptr=(unsigned int*)&temp;
s = *ptr >> 31;
e = *ptr & 0x7f800000;
e >>= 23;
m = *ptr & 0x07fffff;
printf("sign = %x\n",s);
printf("exponent = %x\n",e);
printf("mantissa = %x\n",m);
return 0;
}这里使用min变量来更改最终数字.我使用min=pow(2,-129)、pow(2,-128)和pow(2,-130)来查看结果,而saw 丹玛尔 number appear.This wiki页面解释了这一切。
https://stackoverflow.com/questions/26727611
复制相似问题