---
title: "How to round off numbers in an array [duplicate]?"  
description: "How to round off numbers in an array [duplicate]?"  
author: "Allen Scott"  
published: 2014-10-29  
updated: 2014-10-29  
canonical: https://www.mindstick.com/forum/2451/how-to-round-off-numbers-in-an-array-duplicate  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How to round off numbers in an array [duplicate]?

I cannot find any [pattern](https://www.mindstick.com/forum/2314/what-is-the-mvp-and-mvc-pattern) rounding off doubles in an array. I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to make a [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) that will [input](https://www.mindstick.com/forum/159209/how-can-i-read-convert-an-input-stream-into-a-string-in-java) a double like grades,money etc., and [round](https://answers.mindstick.com/qa/45311/what-was-the-agenda-of-the-round-table-conference-1930-1932) it off in a whole number.

## Replies

### Reply by Anonymous User

Have you tried Math.round() ?\

```
import java.lang.*; public class MathDemo {    public static void main(String[] args) {       // get two float numbers      float x = 1654.9874f;      float y = -9765.134f;       // find the closest int for these floats      System.out.println("Math.round(" + x + ")=" + Math.round(x));      System.out.println("Math.round(" + y + ")=" + Math.round(y));    }}
```


---

Original Source: https://www.mindstick.com/forum/2451/how-to-round-off-numbers-in-an-array-duplicate

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
