1 abs > 1 compare

来源: 2008-02-13 08:35:15 [旧帖] [给我悄悄话] 本文已被阅读:

1 abs = 2 computer instruction
1 compare = 1 computer instruction

logic operations(or,and,xor,not etc), plus or subtraction, (+/-), compare (>,
multiplier/div (on a 32 bit size value in a 32 bit cpu) cost 1 cpu instruction too, but they are more expensive. div is the most expensive cpu instruction.

memory lookup (such as retrieve a number from array, etc int a= array[1])is more expensive it involves IO in memory