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 个)

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 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by