From help-request at octave dot org Thu Jan 5 05:47:44 2006 Subject: Re: rational numbers only From: Geraint Paul Bevan To: Jorge Barros de Abreu CC: help at octave dot org Date: Thu, 05 Jan 2006 11:43:19 +0000 -----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 -------------------------------------------------------------