[Top][All Lists]

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

Re: rational numbers only

From: David Bateman
Subject: Re: rational numbers only
Date: Thu, 05 Jan 2006 12:48:07 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20040923)

Jorge Barros de Abreu wrote:


?????Which the variable name that force maxima to work with ratonal numbers
For example, when in octave is inserted:


the answer is:

ans = 3.5000

but i will like that the answer was:

ans = 7/2

the desired answer is 7/2, not 3.5.

Is it possible ou alread implemented??


Possible solutions

[n,d] = rat(1+0.5+1/3+5/3); str = sprintf("%d/%d",n,d)

or more concisely

str = rats(1+0.5+1/3+5/3)

If there is trouble with precision that can be written as

symbols; str = rats(to_double(vpa(1) +vpa(0.5)+vpa(1)/vpa(3)+vpa(5)/vpa(3)))


David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary

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

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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