# Function Reference

# Round

Returns a number rounded to a specified number of decimal places.

Round ( expression [, decimalplaces] )

## Parameters

expression | Any valid numeric expression.
decimalplaces | [optional] Number indicating how many places to the right of the decimal are included in the rounding. If omitted, Round returns an integer.

## Return Value

Returns rounded number.

## Remarks

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

## Related

Ceiling, Floor, Int, Number, Random

## Example

### Example 1

    #include <MsgBoxConstants.au3>

    Local $iRound1 = Round(-1.582, 1) ; Returns -1.6.
    Local $iRound2 = Round(3.1415, 9) ; No change is made.
    Local $iRound3 = Round(123.5, -1) ; Returns 120

    MsgBox($MB_SYSTEMMODAL, "", "The following values were rounded: " & @CRLF & _
            $iRound1 & @CRLF & $iRound2 & @CRLF & $iRound3)

### Example 2

    #include <MsgBoxConstants.au3>

    Example()

    Func Example()
        ; Assign a Local variable an Array which will contain the rounded numbers.
        Local $aRound[5]

        $aRound[0] = Round(-1.582, 1) ; Returns -1.6.
        $aRound[1] = Round(3.1415, 9) ; Returns 3.1415
        $aRound[2] = Round(123.5, -1) ; Returns 120.
        $aRound[3] = Round(123.5) ; Returns 124.
        $aRound[4] = Round(50) ; Returns 50.

        ; Display the results.
        For $i = 0 To UBound($aRound) - 1
            MsgBox($MB_SYSTEMMODAL, "", "Round" & $i & ": " & $aRound[$i] & @CRLF)
        Next
    EndFunc   ;==>Example