検索条件
全4件
(1/1ページ)
#include <float.h>
#include <math.h>
#include <stdio.h>
int main() {
volatile double r, x;
_controlfp(_PC_53, _MCW_PC);
x = 2.;
_controlfp(_RC_UP, _MCW_RC);
r = sqrt(x);
_controlfp(_RC_NEAR, _MCW_RC);
printf("%.17g\n", r);
_controlfp(_RC_DOWN, _MCW_RC);
r = sqrt(x);
_controlfp(_RC_NEAR, _MCW_RC);
printf("%.17g\n", r);
return 0;
}
こんな感じのソースで、なぜか表示される値が同じになってしまう。
>> format hex
>> system_dependent('setround', inf)
>> 1/3
ans =
3fd5555555555556
>> sqrt(2)
ans =
3ff6a09e667f3bcd
>> system_dependent('setround', -inf)
>> 1/3
ans =
3fd5555555555555
>> sqrt(2)
ans =
3ff6a09e667f3bcd
除算の丸めは変わっているけどsqrtは変わってない。windows用のmatlabはVisual C++でmakeされているのだろうか。