Average

Syntax:

    integer_variable = Average(byte_variable1 , byte_variable2)

Command Availability:

Available on all microcontrollers.

Explanation:

A function that returns the average of two numbers. This only supports byte variables.

It provides a very fast way to calculate the average of two 8-bit numbers.

Example:

 average_value = Average(8,4)   ' Will return 6          ' <<< the Average instruction

Key line: Average(8,4) — adds the two byte values and halves the result in a single fast operation, returning 6.

See Also:

  • Abs — related command in the same category
  • Difference — related command in the same category