Difference

Syntax:

    Difference ( word_variable1 , word_variable2 ) or
    Difference ( byte_variable1 , byte_variable2 )

Command Availability:

Available on all microcontrollers.

Explanation:

A function that returns the difference between two numbers. This only supports byte or word variables.

Example:

    Difference( 8 ,4 ) ' Will return 4          ' <<< the Difference instruction
    Difference( 0xff01 , 0xfffa ) ' Will return 0xf9 or 249d

Key line: Difference( 8 ,4 ) — returns the unsigned distance between the two values (4), regardless of which argument is larger.

See Also:

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