fundamental multiplication problems with Matlab2010-2011!!!!
7 ビュー (過去 30 日間)
古いコメントを表示
Dear all!
today I discover something very very very stupid in Matlab.0 This is the code I wrote:
x =
8.4600
>> y=x*10000
y =
8.4600e+004
>> y-84600
ans =
1.4552e-011
HOW THIS IS POSSIBLE????? it's only a multiplication!
3 件のコメント
Jan
2012 年 8 月 30 日
@gringorie: You are in a good company - otherwise this topic would be discussed in the "seldom asked questions". Reading the FAQ is a good idea for all software you use, because it is worth to profit from the problems of others.
採用された回答
gringoire
2012 年 8 月 30 日
4 件のコメント
Sean de Wolski
2012 年 8 月 30 日
Yes. It means you can't use ismember to get reliable results with floating points.
For the most part when there is something common like this you will have no reason to reinvent the wheel:
その他の回答 (1 件)
James Tursa
2012 年 8 月 31 日
For educational purposes:
>> x = 8.46
x =
8.4600
>> num2strexact(x)
ans =
8.46000000000000085265128291212022304534912109375
>> y = x * 10000
y =
8.4600e+004
>> num2strexact(y)
ans =
8.4600000000000014551915228366851806640625e4
>> y - 84600
ans =
1.4552e-011
>> num2strexact(ans)
ans =
1.4551915228366851806640625e-11
You can find num2strexact here:
href = ""<http://www.mathworks.com/matlabcentral/fileexchange/22239-num2strexact-exact-version-of-num2str</a>>
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!