Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to round up in java

int x = 3.14;

Math.round(x);
//Rounds to nearest int
Math.ceil(x);
//Rounds up to int
Math.floor(x);
//Rounds down to int
Comment

java round up

double test = 0.01;
// rounds up to the next INTEGER
test = Math.ceil(test);  // 1.0


double test2 = 1.0;
// does not round if decimal is 0
test2 = Math.ceil(test2);  // 1.0
Comment

PREVIOUS NEXT
Code Example
Java :: Java Looping Through Array Elements 
Java :: java ignore catch 
Java :: hashmap sort ascending 
Java :: work with arrays java 
Java :: reverse number in java 
Java :: java.lang.IllegalArgumentException: View=DecorView@5fd145b[MainActivity] not attached to window manager 
Java :: Java JTextArea text size 
Java :: iterate list in java 
Java :: get index of element in array java 
Java :: how to sort arraylist 
Java :: java create xml 
Java :: valueof in java 
Java :: argumentcaptor java mockito 
Java :: findone in spring boot 2.4.1 
Java :: java 8 stream option 
Java :: java stringbuilder set value 
Java :: android iterate through radio group java 
Java :: char array to string in java 
Java :: reading string after double in java 
Java :: write content to file java 
Java :: combinations in java 
Java :: remove java ubuntu 20.04 stackoverflow 
Java :: Using multiple delimiters with String Tokenizer 
Java :: frame background changing in java 
Java :: java print 2d array row and column 
Java :: get free player inventory slots spigot 
Java :: android studio Toast usage 
Java :: read excel file in java and store into arraylist 
Java :: How to make a Java Main Menu Loop after using a case 
Java :: how to copy an object in java 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =