summing up a large single precision array
古いコメントを表示
Hi all,
I was trying to sum up the array of large single format array, I got significantly different results to what I got using double precision.
LCOI, which is the vector to be summed up, is a 25,233,291-by-1 single-precision array. Here are the results about summing it up in the different settings of precision.
---------------------------------------------------
>> sum(LCOI)
ans =
5.7487e+09
>> sum(double(LCOI))
ans =
4.9164e+09
>>
---------------------------------------------------
For more information, here is the histogram for the values of LCOI, plots of mean values calculated from the two data types.

I suspected the overflow at the first time because the array is kinda large, but I found the maximum number that the single precision can express is far larger than that.
Could it be the lower "resolution" of single precision data than that of double precision? And is it possible that it can cause that 17% of difference?
Thanks in advance,
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!