Mojo function
round
round[T: Roundable, //](number: T) -> $0
Get the rounded value of the given object.
Parameters:
- T (
Roundable
): The type conforming to Roundable.
Args:
- number (
T
): The object to get the rounded value of.
Returns:
The rounded value of the object.
round(number: FloatLiteral) -> FloatLiteral
Get the rounded value of the given FloatLiteral.
Args:
- number (
FloatLiteral
): The FloatLiteral to get the rounded value of.
Returns:
The rounded value of the object.
round[T: Roundable, //](number: T, ndigits: Int) -> $0
Get the value of this object, rounded to a specified number of digits after the decimal point.
Parameters:
- T (
Roundable
): The type conforming to Roundable.
Args:
- number (
T
): The object to get the rounded value of. - ndigits (
Int
): The number of digits to round to.
Returns:
The rounded value of the object.
round(number: FloatLiteral, ndigits: Int) -> FloatLiteral
Get the value of this FloatLiteral, rounded to a specified number of digits after the decimal point.
Args:
- number (
FloatLiteral
): The FloatLiteral to get the rounded value of. - ndigits (
Int
): The number of digits to round to.
Returns:
The rounded value of the object. Positive ndigits to the right of the decimal, negative ndigits to the left.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!