Yes that is true, integer divisions (on the processor) are slow. However multiplication is fast. A very commen optimisation by most compliers convert integer divisions by a fixed number (eg x /10000) in source into integer multiplication instructions which are fast. this is what i'm refering too. You can check this by creating a simple c program which does a division and then dis!@#$%^&*ble it #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int x,y;
x= 0;
y = 0;
printf("\n Enter an Number: ");
scanf("%i",&x);
int ans = x / 10000;
printf("\n Answer / 10000 = %i\n", ans);
system("PAUSE");
return 0;
} Dis!@#$%^&*mbly for optimized exe of code above As you notice there are NO IDIV instructions. The division is carried out using MUL (multiply) 004012F0 /$ 55 PUSH EBP
004012F1 |. B8 10000000 MOV EAX,10
004012F6 |. 89E5 MOV EBP,ESP
004012F8 |. 83EC 18 SUB ESP,18
004012FB |. 83E4 F0 AND ESP,FFFFFFF0
004012FE |. E8 7D050000 CALL divide.00401880
00401303 |. E8 F8000000 CALL divide.00401400
00401308 |. C745 FC 000000>MOV DWORD PTR SS:[EBP-4],0 ; ||||
0040130F |. C70424 0030400>MOV DWORD PTR SS:[ESP],divide.00403000 ; ||||ASCII 0A," Enter an "
00401316 |. E8 DD050000 CALL <JMP.&msvcrt.printf> ; |||\printf
0040131B |. C70424 1530400>MOV DWORD PTR SS:[ESP],divide.00403015 ; |||ASCII "%i"
00401322 |. 8D4D FC LEA ECX,DWORD PTR SS:[EBP-4] ; |||
00401325 |. 894C24 04 MOV DWORD PTR SS:[ESP+4],ECX ; |||
00401329 |. E8 C2050000 CALL <JMP.&msvcrt.scanf> ; ||\scanf
0040132E |. C70424 1830400>MOV DWORD PTR SS:[ESP],divide.00403018 ; ||ASCII 0A," Answer / "
00401335 |. 8B4D FC MOV ECX,DWORD PTR SS:[EBP-4] ; ||
00401338 |. BA AD8BDB68 MOV EDX,68DB8BAD ; ||
0040133D |. 89C8 MOV EAX,ECX ; ||
0040133F |. F7EA IMUL EDX ; ||
00401341 |. 89C8 MOV EAX,ECX ; ||
00401343 |. C1F8 1F SAR EAX,1F ; ||
00401346 |. C1FA 0C SAR EDX,0C ; ||
00401349 |. 29C2 SUB EDX,EAX ; ||
0040134B |. 895424 04 MOV DWORD PTR SS:[ESP+4],EDX ; ||
0040134F |. E8 A4050000 CALL <JMP.&msvcrt.printf> ; |\printf
00401354 |. C70424 2F30400>MOV DWORD PTR SS:[ESP],divide.0040302F ; |ASCII "PAUSE"
0040135B |. E8 88050000 CALL <JMP.&msvcrt.system> ; \system
00401360 |. C9 LEAVE
00401361 |. 31C0 XOR EAX,EAX
00401363 \. C3 RETN I've attached the exe if you need to verify divide.exe