Is there a data type has higher precision than double?

In Matlab, I only know single, double two type of floating points number. Is there any type has higher precision? If not, is it possible to define one by myself?

답변 (2개)

John D'Errico
John D'Errico 2016년 6월 2일
편집: John D'Errico 2016년 6월 2일

1 개 추천

No, there is not a standard data type with higher precision than double.
Yes, you can use symbolic toolbox to get that. Or you can use my own HPF toolbox, downloadable from the file exchange.
And yes, of course, you CAN define your own class, providing higher precision. After all, that is exactly what I did when I wrote HPF. But then you would need to spend a significant amount of time to provide the accompanying code for all operations on those numbers. Everything from adds, multiplies, linear algebra, trig functions, etc. Whatever you use will need to be provided by you.
Or, you could use Java tools. But there too, only a few basic operations are defined. (Yes, I considered the Java ops when I wrote HPF. I had valid reasons for writing it myself.)
SHOULD you use higher precision? It is often the case (and this is said by a person who has written more than one high precision toolbox) that simple good numerical analysis is sufficient to avoid the need for high precision. Too often I think that people resort to high precision out of laziness, being unwilling to do the extra work to avoid the need. That is not to say that it is never necessary. HPF is fun to use and was a great deal of fun to write.
And don't forget that higher precision costs time. Any such tool will be WAY slower than double precision computations.

댓글 수: 1

It's really useful. And one more question. What about the function 'exp' in Matlab? If I have a variable a which is hpf type. What about the number exp(a)? It's coming from e^(a). But is e is a hpf type or only a double number?

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

카테고리

도움말 센터File Exchange에서 Argument Definitions에 대해 자세히 알아보기

태그

질문:

2016년 6월 2일

댓글:

2016년 6월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by