Difference Subtracting Double Precision from Single Precision
8 ビュー (過去 30 日間)
古いコメントを表示
Can you explain the results for the lines below
a=99999999; b=single(a); b-a
1
a=20000001; b=single(a); b-a
-1
0 件のコメント
採用された回答
Matt Fig
2012 年 9 月 19 日
編集済み: Matt Fig
2012 年 9 月 20 日
Yes, have a look at
E = eps(b)
When you convert to single you are going to get the nearest single value to a within E. To see what you are dealing with, look at this:
a = (999999999-32):(999999999+34); b = single(a);
fprintf('%10.0f %10.0f \n',[a;double(b)])
Now when you do
c = b-a
MATLAB does the equivalent of this:
c2 = single(double(b)-a)
Also have a look at this:
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!