Unknown x: x+1=1 in machine numbers
古いコメントを表示
回答 (1 件)
Matt Fig
2012 年 11 月 2 日
x = eps(1)/2;
If x is larger than this, 1+x>1.
11 件のコメント
Matt Fig
2012 年 11 月 2 日
Oh, you didn't say you were trying to get to this number by calculation! Sure:
x = 1;
while x+1>1
x = x/2;
end
Matt Fig
2012 年 11 月 2 日
Dude, please take the time to use the {} Code button!
JIM
2012 年 11 月 2 日
JIM
2012 年 11 月 2 日
Matt Fig
2012 年 11 月 2 日
What do you mean "the largest x"? That code returns a number that is not the largest x one can add to 5000 such that: (x+5000)==5000
The largest number x one can add to any y such that
(x+y)==y % is x=eps(y)/2
So this is how you check your code..
JIM
2012 年 11 月 2 日
Matt Fig
2012 年 11 月 3 日
Like I said, you will get close with the code I gave you above, then you can zoom in by looking at smaller differences than x/2. Is this homework?
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!