double data type error

3 ビュー (過去 30 日間)
Jaykishan Solanki
Jaykishan Solanki 2024 年 7 月 9 日
コメント済み: Jaykishan Solanki 2024 年 7 月 9 日
I am using double as data type for my code yet I am only getting values upto four decimal places, I am not sure whether this is correct or not.

採用された回答

surya venu
surya venu 2024 年 7 月 9 日
Hi,
In MATLAB, the "double" data type provides floating-point numbers with double precision, which means it can represent numbers with a high degree of accuracy. However, the display format in the MATLAB Command Window might be limiting the number of decimal places you see.
To check if the values are actually stored with higher precision, you can change the display format. MATLAB's default display format is "short", which shows up to four decimal places. You can change this to "long", which shows up to 15 decimal places for "double" precision numbers.
Here is an example MATLAB code:
format long
a = 1.123456789012345;
disp(a)
1.123456789012345
For more information check out:
Hope it helps.
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 7 月 9 日
Personally, I prefer
format long g
Jaykishan Solanki
Jaykishan Solanki 2024 年 7 月 9 日
Thank you @surya venu

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by