ここでは、フロート変数から128.0と129.0を2M回減算します。
#include "stdafx.h"
#include<stdlib.h> //is this the problem? Or am i doing something wrong?
int main()
{
float d1=3.0e9;
printf("\n before: %f \n",d1);
for(int i=0;i<2000000;i++) d1=d1-128.0; //doesnt change!
printf("\n after : %f \n",d1);
for(int i=0;i<2000000;i++) d1=d1-129.0; //does change!
printf("\n after2: %f \n",d1);
//is 129 is the minimum step for sub/add ? Isnt this wrong?
//Is this about exponential part 10^9 ?
getchar();
return 0;
}
出力:
質問: 129よりも小さいオペランドを加算/サブスクライブしても、このフロートが変化しないのはなぜですか?初期フロート値3.0e9を選択したので?
初期値3.0e10を選択すると、初期化と減算の両方が機能しません。
初期値3.0e8を選択した場合、最小変更は17です。したがって、16は変更されません。:(
だから、答えてくれてありがとう、。初期値が小さくなると、精度に応じて最小ステップが小さくなります。
VC++2010エクスプレス。WindowsXP32ビット。pentium-m