```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Converting irrational numbers to rational
Date: Sat, 31 Jul 2010 20:07:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <i31vp9\$ihv\$1@fred.mathworks.com>
References: <i30s3d\$ptm\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1280606825 19007 172.30.248.35 (31 Jul 2010 20:07:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 31 Jul 2010 20:07:05 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:657991

"William " <william.baxter@oit.edu> wrote in message <i30s3d\$ptm\$1@fred.mathworks.com>...
> Sorry, I am very new to matlab.  I would like to display my answers in rational numbers instead of scientific notation which I am getting now.  Anything helps, really just looking for the help doc that has info on this subject.
- - - - - - - - - -
Also check out the 'rat' and 'rats' (no relationship with the rodent) matlab functions.

For some theoretical background read the Wikipedia article at:

http://en.wikipedia.org/wiki/Continued_fraction

In particular read the section "Best rational approximations".

Additional note: You mentioned "irrational" numbers in your subject title, but bear in mind that all of matlab's floating points numbers are of necessity rational - in fact they are all integers divided by various powers of two - the smallest positive double precision floating point number is 1/2^1074 and all its other numbers are integer multiples of this.

Roger Stafford
```