Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've always wondered how people who write code could possibly be unaware of the modulo operator. In the 8-bit and 16-bit CPU era, or even just when working with data types of that width, one has to be aware of wraparound / overflow if the value gets too large and that's what modulo is. Is it just developers who came of age in the 64-bit CPU era that have this gap?
 help



>I've always wondered how people who write code could possibly be unaware of the modulo operator.

Worked for 25+ years in regular business software - banking , insurance etc. I never recollect using the modulo operator.


When one's primary handling of numbers comes down to either linear (single-dimensional) lists or money, then you won't use modulo very much.

But any time you're walking over a discrete multidimensional list packed into a linear list, or walking over any discrete periodic signal (one very common example would be walking a linear array of screen pixels, walking over pcm samples in an audio waveform, literally 100% of GPU programming and 90+% of SIMD programming) you will want to be able to translate between "how far from the start am I" and "how far into the current cycle am I", and modulo handles that.

Similarly for almost anything involving time calculations (and for the same reason: because they are periodic). Modulo is literally described as "clock arithmetic" after all.

Here you can find Tempestt Bledsoe singing about it, lol https://youtu.be/fqtzqcJ6agE?t=570s

So you are absolutely correct that there do exist avenues in programming which can dodge this particular raindrop, I hope you aren't opposed to the idea that they are at least few and far between? ;)


>I hope you aren't opposed to the idea that they are at least few and far between? ;)

Absolutely not. Part of the reason why I mentioned the areas that I work in, are for that reason. I suspect that the vast majority of software jobs are of the kind I mentioned.

As the HN user 'strken' correctly pointed out, fizzbuzz can stump an experienced job candidate if he has never used the modulo operator.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: