Arithmetic Operations
This note focuses on the basic arithmetic functions; for the basic operations exposed via operators, see Matlab Matrix Operations and Matlab Array Operations.
Modulo Division
mod: remaindermod(a,m)returns the remainder after division of a by m- =
a - m.*floor(a./m) mod(a,0)returns a
rem: remainderrem(a,m)returns the remainder after division of a by m- =
a - m.*fix(a./m) rem(a,0)returnsNaN
idivide: integer divisionidivide(a,b,<opt>)returns a/b rounded according to opt- opt defaults to
'fix'; allowed values are'fix','floor','ceil','round'
Rounding
roundrounds half up away from 0fixrounds towards 0floorrounds towards negative infinityceilrounds towards positive infinity