How to Get Quotient in Integer Division in Matlab?

I wonder how to get quotient in integer division in MATLAB? Thanks and regards!

3 Answers

Use idivide:

C = idivide(A, B) is the same as A./B except that fractional quotients are rounded toward zero to the nearest integers.

There's a third optional parameter for controlling the rounding behavior that's explained on the MathWorks site that I linked to.

Simply, put as following:

floor(A/B)

floor command rounds the value to the nearest integer, towards negative infinity (-inf).

just divide and round down?

or are you talking about integer division, in which case use idivide

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest