help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rational numbers only


From: Geraint Paul Bevan
Subject: Re: rational numbers only
Date: Thu, 05 Jan 2006 11:43:19 +0000
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051013)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jorge Barros de Abreu wrote:

> ans = 3.5000
> 
> but i will like that the answer was:
> 
> ans = 7/2
> 
> the desired answer is 7/2, not 3.5.

The 'rat' command will find a rational approximation to a number:

octave> [n,d] = rat(1+0.5+1/3+5/3); [num2str(n), '/', num2str(d)]
ans = 7/2

- --
Geraint Bevan
http://www.mech.gla.ac.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkO9BlEACgkQcXV3N50QmNN1tACfeAMkFJuUPkjdEd/q7K2+9UU9
hMIAnjVp5kEcRmANC030eRwAcIZByk4y
=3N0e
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]