4

I'm working on sml project in which I have to implement these two function rem & mod for custom datatype.

I know the definition of remainder rem.
dividend = divisor * quotient + remainder

What is the definition of mod? Please explain me the difference between these in simple words.

LearningGiraffe
  • 145
  • 3
  • 11

1 Answers1

5

In i mod j, the result has the same sign as j.

In i rem j, the result has the same sign as i.

You can look up the details in the documentation for Basis.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610