Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How expensive is fmod in terms of processor time?

Tags:

c++

math

In my game, I need to ensure that angles do not exceed 2 pi. so I use fmod(angle,TWO_PI);

Is this noticeably expensive to do about 100 times per second?

like image 501
jmasterx Avatar asked May 22 '11 17:05

jmasterx


1 Answers

100 times per second? That's almost zero, you shouldn't trouble yourself.

Even if fmod takes 100 clock cycles - that's 10,000 cycles/Sec. For 1 1GHz CPU - that's 0.001% CPU.

BTW: why do you want to do fmod of TWO_PI? If you're going to take sin() or cos() - you can skip it.

like image 73
Lior Kogan Avatar answered Oct 05 '22 03:10

Lior Kogan