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

Правка en1, от 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!

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Fostok 2025-06-11 23:26:22 2 Tiny change: 't’s common said that' -> 't’s commonly said that'
en1 Английский Fostok 2025-06-11 17:52:45 392 Initial revision (published)