Function: math.max

Returns the maximum of two numbers.

If both numbers are integers, returns an integer; otherwise, afloating-point number.

Arguments

Arguments
xAn integer or floating-point number.
yAn integer or floating-point number.

Raised exceptions

Exceptions
TypeErrorIf at least one ofx ory is not an integer or floating-point number.

Examples

# Return maximum of two numbers# For example, returns `123`-returnStep:return:${math.max(123,-456.7)}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.