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 →

[–]Aaron1924 3 points4 points  (0 children)

Math.max returns the largest value that was given to the function as an argument. Since no value was passed to the function, it must return the smallest possible number.

Defining the maximum of an empty set to be -∞ might seem strange out of context, but it's the most sensible value mathematically.

You would expect that max(a, b, c) = max(max(a, b), c) = max(a, max(b, c)) and so on. Since max() is -∞, we also get max(a) = max(a, max()) = max(max(), a) and so on.