what is the difference between data types single and double in simulink ?

188 ビュー (過去 30 日間)
Gokul Prassad
Gokul Prassad 2019 年 5 月 8 日
コメント済み: Gokul Prassad 2019 年 5 月 8 日
I tried to change the data type uint16 to double and i was getting an output of 10 digit number for inputs of a constant decimal number and 1 digit number.
But when I tried the same with data type single, I got the right anwer (with decimal points).
Kindly explain.
  2 件のコメント
Raj
Raj 2019 年 5 月 8 日
編集済み: Raj 2019 年 5 月 8 日
Not very clear. Can you rephrase or maybe give an example?
Gokul Prassad
Gokul Prassad 2019 年 5 月 8 日
Dear Raj,
I just wanted to know the difference between datatypes 'single' and 'double'.
Also what happens to the output when one uses input datatype 'double' in the place of 'single' ?

サインインしてコメントする。

採用された回答

Raj
Raj 2019 年 5 月 8 日
編集済み: Raj 2019 年 5 月 8 日
Your floating point data (Decimal Data) can be represented either via Single data type of Double data type. The basic difference being the precision between the two types. Now contary to the name, its not the precision that doubles. Its the number of Bits used in your computer memory for storing the data that doubles. Single datatype uses 32 bits of memory whereas Double uses 64 bits of memory. With higher precision, you get better accuracy but at the cost of memory and processing. This being a nutshell summary, you can google out for details. Hope this helps!
  1 件のコメント
Gokul Prassad
Gokul Prassad 2019 年 5 月 8 日
This being my basic understanding i attempted to multiply two data with datatypes 'uint16' and 'double'. I set the required output datatype from the product block to be 'double'. The output was a 10 digit number. When i converted all data types to double, I got the same weird result.
But when I converted all datatypes to single, I got the correct answer which was decimal number. Can you explain this please ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by