sub01's calculation might takes long cpu circle

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

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.