Two decimal places
Input
format_number(3.14159, 2)
Output
3.14
Rounded to two decimal places.
Full lesson preview
Return a string representation of a number rounded to a specified number of decimal places, preserving trailing zeros.
Problem statement
Task
Examples
Input
format_number(3.14159, 2)
Output
3.14
Rounded to two decimal places.
Input format
Output format
Constraints
Samples
Input
format_number(2, 3)
Output
2.000
Integer input should be formatted with trailing zeros to match decimals.