|
Number.round Method
Rounds the number to the nearest integer.
object.round(prec)
Arguments
- object
- Required. Always the name of a Number object.
- prec
- Optional. The number of places after the decimal at which to round. This value can be negative.
If prec is omitted, the Number.round() method rounds the number to the nearest integer.
Return Value
The rounded number.
Remarks
The following example illustrates the use of the Number.round method.
Console.Writeln((-45.23456).round()); // Outputs -45 to the Console.
Console.Writeln((-45.23456).round(2)); // Outputs -45.23 to the Console.
Console.Writeln((-45.23456).round(-1)); // Outputs -50 to the Console.
Requirements
|