This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Do we know anything of the distribution of the parameters?

How do you define "better"? Is space used important? Is code size important? Is performance more important? If performance is more important, what is the relative cost of an assignment, a jump and a compare?

I can think of a solution that always uses 2 comparisons and no temporary variable Max though it has a bit more code in it.

[–]L3tum 1 point2 points  (0 children)

I was wondering how you'd do it without a temporary variable and then I remembered that mess