Is there a numerical type that uses arbitrary precision ?

1 view (last 30 days)
I'm looking for a numerical type that doesn't loose precision at all (for operations: + - * /).
For example in Boost-C++ thete is a type cpp_ratinal, that holds the number as arbitrary long numerator, and arbitrary long denumerator.
Is there some equivalent in Matlab ?

Answers (2)

John D'Errico
John D'Errico on 19 Aug 2014
Yes. A few options.
You can use the symbolic toolbox.
You can use the fractions toolbox, which allows use of my own vpi toolbox for the numerator and denominator, thus arbitrarily long integers for each.
Or you can use my own HPF toolbox for arithmetic on floats of arbitrary length, so while it only has a user defined precision, that will be as large as you choose.

Star Strider
Star Strider on 19 Aug 2014
There is. See the documentation for rats and related core MATLAB functions.
The format option also offers rational output, but not arbitrarily long numerators and denominators.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!