RoundSingle

Syntax:

    rounded_single_value = RoundSingle( single_variable )

Command Availability:

Available on all microcontrollers.

Explanation:

The RoundSingle function returns a floating-point number that is a rounded version of the specified number.

This operates the same as Microsoft’s floor().

Example:

    Dim singlevariable As Single
    Dim rounded_single_value As Single
    singlevariable = 7.85

    rounded_single_value = RoundSingle( singlevariable )          ' <<< the RoundSingle instruction
    ' rounded_single_value now holds 7.0

Key line: RoundSingle( singlevariable ) — rounds 7.85 down to 7.0, floor-style, rather than to the nearest whole number.

See Also:

  • Abs — related command in the same category
  • Int — truncating to an integer type instead of rounding within Single