Round

From AutoIt Wiki

Jump to: navigation, search

Returns a number rounded to a specified number of decimal places. Adapted from AutoIt docs.

Contents

Syntax

Round(expr [,decimalplaces])

Parameters

exprAny valid numeric expression.
decimalplacesNumber indicating how many places to the right of the decimal are included in the rounding. If omitted, Round returns an integer.(Optional)

Note: The decimalplaces parameter can be negative which allows you to round to the ones, tens, hundred, etc. place. Up to fifteen digits of a number are displayed, and note that decimalplaces will never pad a number with trailing zeros.

Return Value

Returns a rounded number.

Example

$x = Round(-1.582, 1)  ;returns -1.6
$y = Round(3.1415, 9)  ;no change
$z = Round(123.5, -1)  ;returns 120

Related Functions

Int Number

Personal tools