Thursday, 28 January 2016

Julia: Get quotient and remainder at a time

By using following functions, you can get quotient and remainder at a time.

Function
Description
divrem(x,y)
returns (div(x,y),rem(x,y))
fldmod(x,y)
returns (fld(x,y),mod(x,y))


julia> divrem(10, 3)
(3,1)

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

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

julia> fldmod(10, 3)
(3,1)

julia> fldmod(10, -3)
(-4,-2)

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





Previous                                                 Next                                                 Home

No comments:

Post a Comment