error in large integers
조회 수: 1 (최근 30일)
이전 댓글 표시
I am currently working with fractions involving 10digit integers.
for example, typing 1168347147/863334886 into MATLAB produces the answer 4045/2989.
But I want to store the fractions exactly. How do I go about doing this?
Many thanks.
댓글 수: 0
답변 (2개)
Aldin
2012년 3월 21일
Hi,
use vpa functon
for example:
vpa('4045/2989',100) ---> for hundred digits
댓글 수: 5
Walter Roberson
2012년 3월 22일
If you have the symbolic math toolbox, then
sym('1168347147/863334886')
Note that the result will be a symbolic number, not a double precision number.
댓글 수: 3
Walter Roberson
2012년 3월 22일
Yes, if you do have the symbolic toolbox then you would be able to use symbolic numbers in further calculations; the results would be symbolic numbers.
There might be places along the way where you needed to convert the symbolic numbers to double precision using double(), as there are MATLAB routines that cannot work with symbolic numbers.
Aldin
2012년 3월 22일
Hello sir Walter,
Can you please explain:
>> sym('1168347147/863334886')
ans =
1168347147/863334886
>> ans * 1,4
ans =
8178430029/4316674430
--------------------------
But if i check last result with 'vpa' function i got this:
>> vpa('863334886*1,4)
ans = 1208668840.4
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!