help-octave
[Top][All Lists]
Advanced

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

"proper" integer division


From: Peter L.
Subject: "proper" integer division
Date: Tue, 11 Mar 2008 14:14:14 +0100

I noticed that Octave does integer division by rounding to the nearest
integer (probably for compatibility with Matlab) instead of floor'ing as
in C, so (as mentioned here
http://www.gnu.org/software/octave/doc/interpreter/Integer-Arithmetic.html
)

then int32(5)./int32(8) == 1 and not zero.

Is there a build-in function that will return the correct result, or a
better construction that the following:

% Compute the integer division of a/b
(a-mod(a,b)/b

It would be handy with a simple build-in function that returned the
quotient and the remainder as the "div" function in C does.

Cheers,

Peter.






reply via email to

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