Is there a data type has higher precision than double?

34 vues (au cours des 30 derniers jours)
Yuchi Qiu
Yuchi Qiu le 2 Juin 2016
Commenté : Yuchi Qiu le 3 Juin 2016
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?

Réponses (2)

John D'Errico
John D'Errico le 2 Juin 2016
Modifié(e) : John D'Errico le 2 Juin 2016
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 commentaire
Yuchi Qiu
Yuchi Qiu le 3 Juin 2016
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?

Connectez-vous pour commenter.


James Tursa
James Tursa le 2 Juin 2016

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by