5 ms·
setInterval(clock, 1000 / 100); Is there any reason for writing 1000/100 instead of 10? edit: Thanks guys!
by shocks 14y ago
setInterval(clock, 1000 / 100);
Is there any reason for writing 1000/100 instead of 10?
edit: Thanks guys!
- Riesling 14y agoProbably just to emphasize that clock will be called 100 times per second (which will result in 100 fps).
- Rygu 14y ago100 frames per second. He probably changed that during development.
- estel 14y agoIt's a good way to remind you the figure is in ms, and easily manipulate the interval as a fraction of a second.
- anatoli 14y agoIt just makes it clearer that he wants it to run at 100FPS: (1000ms / desired FPS) The usefulness is more obvious when you want 60FPS, which is not easily represented without rounding.
- dag11 14y agoIt was probably for readability, i.e. "100 times per second". Similarly, people will write (10 * 60 * 60) if the value is seconds and the programmer intends to indicate 10 hours.
- sisk 14y agoI personal do this for legibility and ease of comprehension. Kinda loses its value when dealing with such nicely rounded numbers but, as an example, 1000ms / 24 is easier or me to comprehend as 24 ticks per second than 41.6666ms.