필터 지우기
필터 지우기

double data type error

조회 수: 19 (최근 30일)
Jaykishan Solanki
Jaykishan Solanki 2024년 7월 9일 5:25
댓글: Jaykishan Solanki 2024년 7월 9일 6:18
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일 5:34
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일 5:39
Personally, I prefer
format long g
Jaykishan Solanki
Jaykishan Solanki 2024년 7월 9일 6:18
Thank you @surya venu

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by