4 ms·
Agreed. In my experience, people want to use this modulo operator (e.g. for implementing a ring buffer or wrap-around as you mentioned), but many languages use
by antidesitter 8y ago
Agreed. In my experience, people want to use this modulo operator (e.g. for implementing a ring buffer or wrap-around as you mentioned), but many languages use the other modulo which leads to all sorts of bugs. It doesn’t make sense to me since this modulo is more natural from both a mathematical and an engineering perspective.
- jacobolus 8y agoIt’s because that’s the way CPUs / C do it. Many other language implementors are too lazy to fix it. I have often been thankful that Python does the right thing, and often frustrated that Javascript does not.