
Number rounding
Round a decimal number with an explicit precision and rule.
Your inputs stay in your browser.
Method and assumptions
Method version 1.0.0 · Updated
Round to a precision
Formula: Decimal rounding to p places according to the selected rule
Both dots and commas are accepted as decimal separators. Nearest ties round away from zero: 1.005 → 1.01 and −1.005 → −1.01 at two places. Toward −∞: −1.21 → −1.3 at one place; toward zero: −1.21 → −1.2. Trailing zeros show the selected precision.
- value
- Number to round
- places
- Decimal places
- mode
- Rounding rule
Exact decimal input of at most 80 characters, including sign and separator; 0 to 12 decimal places in the result. Trailing zeros are preserved. No second display rounding.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
console.log(Number((12.3456).toFixed(2))); // 12.35TypeScript
const rounded = Number((12.3456).toFixed(2));
console.log(rounded); // 12.35Python
print(round(12.3456, 2)) # 12.35Java
System.out.println(new java.math.BigDecimal("12.3456").setScale(2, java.math.RoundingMode.HALF_UP)); // 12.35C#
Console.WriteLine(Math.Round(12.3456, 2, MidpointRounding.AwayFromZero)); // 12.35