---
id: math-max
name: Math.max
category: math
kind: namespace-method
tokens: Math.max
sig: Math.max(a, b) -> int
tip: The larger of two values.
order: 1
ns: Math
member: max
---
Returns whichever of a and b is larger. Like Math.min, it works for both int and fixed operands. Use it to hold a value at a floor — for example keeping a countdown at zero instead of going negative, or a health bar from dropping below the minimum. The bare form max(a, b) is kept as a convenience alias.
Parameters:
- `a` — the first value
- `b` — the second value
```ludic
program Countdown {
state CountdownState {
timer: int = 60
}
handler Tick(countdown_st: mut CountdownState) phase Update {
countdown_st.timer = Math.max(countdown_st.timer - 1, 0) # stops at 0, never negative
}
}
```