max
uint8_t max(uint8_t a, uint8_t b)int8 max(int8 a, int8 b)
int max(int a, int b)
float max(float a, float b)
Description
Returns the larger of two numeric values.
Both arguments may be of different numeric types; in that case the result type is promoted to the higher-precision type (float > int > int8 > uint8_t).
Parameter
- a - The first numeric value.
- b - The second numeric value.
Returns
The maximum of a and b. The return type is the dominant type of both arguments.
Example
void main()
{
int a = max(3, 7); // a = 7
float b = max(1.5, 2.5); // b = 2.5
float c = max(2, 1.5); // c = 2.0 (int promoted to float)
}