Name

max()

Description

Determines the largest value in a sequence of numbers, and then returns that value. max() accepts either two or three float or int values as parameters, or an array of any length.

Examples

  • int a = max(5, 9);            // Sets 'a' to 9
    int b = max(-4, -12);         // Sets 'b' to -4
    float c = max(12.3, 230.24);  // Sets 'c' to 230.24
    
  • int[] values = { 9, -4, 362, 21 };  // Create an array of ints
    int d = max(values);                // Sets 'd' to 362
    

Syntax

  • max(a, b)
  • max(a, b, c)
  • max(list)

Parameters

  • a(int, float)first number to compare
  • b(int, float)second number to compare
  • c(int, float)third number to compare
  • list(int[], float[])array of numbers to compare

Return

  • int or float

Related