- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to round a number to n decimal places in Java
Following program shows how to round a number to 2 decimal places.
Example
public class Tester { public static void main(String[] args) { double number = 122.2363534; double result = Math.round(number*100)/100.0d; System.out.println(result); } }
Output
122.24
- Related Articles
- Java Program to Round a Number to n Decimal Places
- Swift Program to Round a Number to n Decimal Places
- Haskell Program to Round a Number to n Decimal Places
- Kotlin Program to Round a Number to n Decimal Places
- C++ Program to Round a Number to n Decimal Places
- I want to round a number to 2 decimal places in SAPUI5. Could anyone help?
- How to round correlation values in the correlation matrix to zero decimal places in R?
- Trying to round a calculation to two decimal places in a new column with MySQL?
- How to format number to 2 decimal places in MySQL?
- Python - Round number of places after the decimal for column values in a Pandas DataFrame
- How can I round a number to 1 decimal place in JavaScript?
- How to round the decimal number to the nearest tenth in JavaScript?
- How to truncate a numerical vector to a specified number of decimal places in R?
- Java program to round a number
- C++ Program to compute division upto n decimal places

Advertisements