Are +, -, *, / Really O(1)? And Why Is Modulo (%) So Slow?

Revision en1, by Fostok, 2025-06-11 17:52:45

I have several questions in mind, like:

1. Is +, -, *, / Actually O(1)? It’s common said that these operations are O(1), but is that always true?

2. Is x % y Slower Than x-(x / y) * y? I’ve heard people say "modulo is slow", so why not just avoid % and use x-(x / y) * y instead?

I hope you understand my curiosity!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Fostok 2025-06-11 23:26:22 2 Tiny change: 't’s common said that' -> 't’s commonly said that'
en1 English Fostok 2025-06-11 17:52:45 392 Initial revision (published)