Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Haskell: Difference between rem Vs mod

For rem operator, Sign of the result is same as sign of x. The remainder (rem) and modulus (mod) are defined as follows:
            rem(X,Y) = X –(X/Y)*Y     (in which X/Y in an integer)
            mod(X,Y) = X – Y * N      (in which N is an integer)

*Main> rem 10 (-3)
1
*Main>
*Main> mod 10 (-3)
-2


For positive integers both mod and rem behave like same.
*Main> rem 10 3
1
*Main> mod 10 3
1


Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Haskell: Difference between rem Vs mod

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×