Type class Integral has two operations quot and div, yet in the Haskell 2010 Language Report it is not specified what they’re supposed to do. Assuming that div is integral division, what does quot differently, or what is the purpose of quot? When do you use one, and when the other?
Type class Integral has two operations quot and div , yet in the Haskell
Share
To quote section 6.4.2 from the Haskell report:
The
quot,rem,div, andmodclass methods satisfy these laws if y is non-zero:quotis integer division truncated toward zero, while the result ofdivis truncated toward negative infinity.The
divfunction is often the more natural one to use, whereas thequotfunction corresponds to the machine instruction on modern machines, so it’s somewhat more efficient.