Answers for "double to int in java"

8

how to change double to int in java

class Scratch{
    public static void main(String[] args){
        double decimal = 5.7;
        System.out.println( (int) decimal );	//casting
        System.out.println( Math.round(decimal * 10) / (double) 10);	//Math.round()
        System.out.println( decimal % 1);	// modulus
        System.out.println( Integer.parseInt( String.valueOf(decimal).substring(0, String.valueOf(decimal).indexOf(".")))); // .substring()
    }
}
Posted by: Guest on February-17-2020
0

double to int

@SuppressWarnings("deprecation")
int Entero=new Double(345.8).intValue();
Posted by: Guest on March-06-2021
0

how to convert double to int in java

double value = 4.3;
int convertedValue = value % 1;
Posted by: Guest on July-12-2021
-1

convert double to int java

double data = 3452.345
int value = (int)data;
Posted by: Guest on May-11-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language