有时我得到一个 nan 作为乘法 no-nan b 和 c 的结果:
double a = b * c; //b = 0, c = 1024, a = nan
或作为 floor() 的结果:
double a = floor(b); //b = 2024, a = nan
sleep() 的重复计算和使用防止了这个问题:
a = b * c; //a = nan
a = b * c; //a = 0
a = floor(b); //a = nan
a = floor(b); //a = 2024
sleep(1);
a = b * c; //a = 0
sleep(1);
a = floor(b); //a = 2024
CPU是 AMD Athlon(tm) 64 X2 双核处理器 3400+
CPU温度:
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp: -1В°C
Core0 Temp: -2В°C
Core1 Temp: +3В°C
Core1 Temp: +7В°C
Adapter: SMBus PIIX4 adapter at 0b00
M/B Temp: +30В°C (low = +0В°C, high = +85В°C)
CPU Temp: +28.5В°C (low = +0.0В°C, high = +85.0В°C)
M/B Crit: +85В°C (hyst = +75В°C)
CPU Crit: +124В°C (hyst = +114В°C)
这个问题可能是 CPU 计时功能的结果吗?还是有其他问题的原因?
更新
我发现以下程序在该机器上产生 nan:
double a, b, c;
while(1) {
a = 0;
b = 1024;
c = a * b; //c will be nan within 10-20 sec.
}