[Top][All Lists]

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

Re: fractional remainder

From: kamaraju kusumanchi
Subject: Re: fractional remainder
Date: Sun, 25 Dec 2005 21:57:50 -0500
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

blah BLABBER wrote:

Howdy folks,

Question: I am a new Octave user and cannot figure out how to grab the remainder of a fraction. For example, if I take 3/4 = 0.75, I just want to grab the 75.

Reason: I would like to check if the remainder is zero in order to determine if a number is odd or even. Any even number divided by 2 will have a remainder of 0, odd numbers will not. I am using this for loop control.

Problem: In Octave, rem(3,4) gives 3. Obviously I do not understand this function. Can you please suggest the appropriate function to use.


Try the mod function.

octave:1> mod(11,2)
ans = 1
octave:2> mod(10,2)
ans = 0
octave:3> mod(3,4)
ans = 3
octave:4> mod(7,4)
ans = 3

To read about a function you can use the help command. To read about rem, type help rem at the octave prompt etc.,


Kamaraju S Kusumanchi

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]