Confusion between real-world and floating-point values
3 ビュー (過去 30 日間)
古いコメントを表示
Life is Wonderful
2022 年 8 月 4 日
コメント済み: Life is Wonderful
2022 年 8 月 4 日
Hello there,
I'm converting floating to real-world data values with the code snippet below.
I notice that after scaling, floating point values are no longer fractional, implying that data loss has occurred.
Thank you in advance
fi(linspace(-5,5,10),true,32,28)
storedInteger(fi(linspace(-5,5,10),true,32,28))
storedInteger(fi(linspace(-5,5,10),true,32,28)) / 2 ^28
I'm expecting fractional length, but I'm wondering where it's gone. Thanks !!
0 件のコメント
採用された回答
Walter Roberson
2022 年 8 月 4 日
You forgot to take into account that an integer data type operated on with a double precision number, returns the integer data type
fi(linspace(-5,5,10),true,32,28)
SI = storedInteger(fi(linspace(-5,5,10),true,32,28))
class(SI)
SI / 2^28
double(SI) / 2^28
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Fixed-Point Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!