• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 03, 2022 |49.2K Views

Java Program to Convert Double to Integer

Description
Discussion

In this video, we will see a JAVA program to convert a double to an integer.

We will see three different approaches to convert double to integer:
1. Using type casting
2. Using double.int value()
3. Using double to the int conversion method

Double data type: The double data type is commonly used for decimal values, just like float. The double data type also should never be used for precise values. The default value is 0.0.

Integer data type: The Integer or int data type is a 32-bit signed 2's complement integer. Its value-range lies between – 2,147,483,648 to 2,147,483,647. Its minimum value is – 2,147,483,648 and maximum value is 2,147,483,647. It is default value is 0. The int data type is generally used as a default data type for integral values but we sure about there is no problem with memory.

Examples:
Input: double = 325.678
Output: 325

Input: double = 21.89
Output: 21

Convert Double to Integer in Java:
https://www.geeksforgeeks.org/convert-double-to-integer-in-java/