if current > max max = current
else if current
worst the CPU instruction cost, 2 compare, 1 assignment
most case: 1 compare 1 assignment or 2 compare
sub01, your solution involves too many plus (which cost same as compare/assignment), multiplier(more expensive than compare), assignment
so I think amei's solution is more optimized.
sub01's calculation might takes long cpu circle
所有跟帖:
•
回复:multiply by 2 is same as bit shift
-sub101-
♂
(73 bytes)
()
02/13/2008 postreply
08:48:02
•
回复:sub01's calculation might takes long cpu circle
-DCD-
♂
(78 bytes)
()
02/13/2008 postreply
09:04:19
•
回复:回复:it doesn't work!
-sub101-
♂
(85 bytes)
()
02/13/2008 postreply
09:09:04
•
回复:it doesn't work! - Yes mistake- thx
-DCD-
♂
(274 bytes)
()
02/13/2008 postreply
09:37:47