lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Main reason: % always gives a non-negative result, even for negative x,
> whereas fmod(x,y) gives a result of the same sign as x.
I'm going to have to think a bit to see when I'd want that, but that is a good point in that it's another argument that they are different operations.

There's a nice paper about the many ways to design a good div/mod pair

The Euclidean definition of the functions div and mod
Author: Raymond T. Boute University of Nijmegen
Published in: ACM Transactions on Programming Languages and Systems (TOPLAS)
Volume 14 Issue 2, April 1992 

but it's behind an ACM pay wall. Searching for it I found a good summary at 

http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf

e