Wednesday 27 January 2016

Julia: Remainder functions

Julia provides following functions to perform remainder and modulus operations.

Function
Description
rem(x, y)
Return remainder (x%y). Sign of the result is same as sign of x.

julia> rem(10, -3)
1

julia> rem(-10, -3)
-1

julia> rem(-10, 3)
-1
mod(x, y)
Performs modulus after division.

julia> mod(10, -3)
-2

julia> mod(10, 3)
1

julia> mod(-10, 3)
2

julia> mod(-10, -3)
-1
mod2pi(x)
Same as mod(x, 2pi).

julia> mod2pi(10)
3.7168146928204133

julia> mod2pi(-10)
2.566370614359173


Please go through following link to know difference between mod and rem functions.


Previous                                                 Next                                                 Home

No comments:

Post a Comment