int and double have different semantics. Consider division. 1/2 is 0, 1.0/2.0 is 0.5. In any given situation, one of those answers will be right and the other wrong.

That said, there are programming languages, such as JavaScript, in which 64-bit float is the only numeric data type. You have to explicitly truncate some division results to get the same semantics as Java int. Languages such as Java that support integer types make truncation automatic for integer variables.

In addition to having different semantics from double, int arithmetic is generally faster, and the smaller size (32 bits vs. 64 bits) leads to more efficient use of caches and data transfer bandwidth.

Answer from Patricia Shanahan on Stack Overflow
🌐
Reddit
reddit.com › r/c_programming › what is the difference between int and double and how do you know when to use them?
r/C_Programming on Reddit: What is the difference between int and double and how do you know when to use them?
February 6, 2015 - Well they can't really be interchanged. An int is used to represent integer numbers (+- whole numbers). While a double is used to represent a double precision floating point number.
Discussions

Newbie: why would you use int over double ever?
Doubles can be imprecise due to floating point rounding errors. For example, you would never use doubles if you were writing banking software that handles money. For example, try computing 1.89 * 792 in Java. Mathematically, you should get 1496.88 as the result. However, because of rounding errors, the value that Java (and other languages) produce is 1496.8799999999999. It's very close to 1496.88, but it's not exactly that amount. If you keep performing computations, the error will only increase in range, and then suddenly you're left wondering why your answers are off by 1 or 2, even when there is nothing wrong with the operations mathematically. More on reddit.com
🌐 r/javahelp
12
1
August 7, 2015
integer - double versus long for large numbers in Java - Stack Overflow
The big difference between long ... can hold integer numbers only, while double is a floating-point number type (it can hold fractions). See: Primitive Data Types ... For population of humans, use long primitive or Long class. The floating-point types trade away accuracy in exchange for speed of execution. These types in Java include ... More on stackoverflow.com
🌐 stackoverflow.com
[Java] Possible lossy conversion from double to int error.

If you want to explicitly tell the compiler that you want to convert the numbers to integers, you should cast them as such. Example: int x = (int)(10.0/2.0) will make x have a value of 5.

Do note, however, that in the case of int birthrate, the operation 1.0/7.0 will simply be 0 when cast to an int.

More on reddit.com
🌐 r/learnprogramming
14
3
March 23, 2014
What is the difference between int and double and how do you know when to use them?
Well they can't really be interchanged. An int is used to represent integer numbers (+- whole numbers). While a double is used to represent a double precision floating point number. The actual size of each is system dependent but a double will be two times the size of a float. I'd recommend reading up on this with an intro to C tutorial or even just something on basic datatypes. More on reddit.com
🌐 r/C_Programming
16
0
February 6, 2015
🌐
W3Schools
w3schools.com › java › java_data_types.asp
Java Data Types
Note: This rule makes Java safer, because the compiler will stop you if you try to mix up types by mistake. If you really need to change between types, you must use type casting or conversion methods (for example, turning an int into a double).
🌐
Sololearn
sololearn.com › en › Discuss › 713076 › what-is-the-difference-between-int-and-double-in-java
What is the difference between int and double in java | Sololearn: Learn to code for FREE!
September 14, 2017 - java · 14th Sep 2017, 6:40 AM ... AM · 👑 Prometheus 🇸🇬 · + 6 · addition to @ vengat Int is whole numbers while double is floating point numbers ·...
🌐
Mount Allison University
mta.ca › ~rrosebru › oldcourse › comp1711 › 171102 › comp1711A › numbers.html
CS 1711
A primitive data type is only a value. It has no methods. This is because primitive data types are provided as part of the java language - not through a java class definition · The java language provides many different primitive data types to represent and store numeric values.
🌐
Quora
quora.com › What-is-the-difference-between-integer-and-double-in-Java-programming-language
What is the difference between integer and double in Java programming language? - Quora
However Int is the most common and frequent data type used as compared to double..in layman language if u want to assign an integer type number to your variable like 1,2,3,4 etc..u use int…and if u want to assign fraction type number...
🌐
Oreate AI
oreateai.com › blog › understanding-the-difference-int-vs-double-in-java › b3280a9cc3a6961d2ce3291f0adb2f05
Understanding the Difference: Int vs Double in Java - Oreate AI Blog
January 15, 2026 - Here lies one of the key differences ... types: while an int can only store whole values ranging from -2 billion to +2 billion approximately, a double can hold much larger ranges due to its ability to include fractional components but at a cost—it consumes ...
Find elsewhere
🌐
Quora
quora.com › What-is-the-difference-between-double-and-integer
What is the difference between double and integer? - Quora
Answer (1 of 2): Integer identifiers (variables or constant) can take only whole numbers as values. There are two varieties of it. One is unsigned whereas the another is signed. Moreover, they can be of different lengths. Popular lengths for integers are 2 bytes (Range 0:6535 or -32768:32767, 4 b...
🌐
Coderanch
coderanch.com › t › 399930 › java › int-double
why use int over double? (Beginning Java forum at Coderanch)
June 12, 2005 - Of course, since the values are all calculated in doubles, you won't get any more precision by converting to ints. I think usually it is a performance issue, since mathematical operations are typically an order of magnitude faster for ints than for doubles. In this particular case, it won't make a difference, since all you are doing is displaying the ints.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
A primitive type is predefined by the language and is named by a reserved keyword. Primitive values do not share state with other primitive values. The eight primitive data types supported by the Java programming language are: byte: The byte data type is an 8-bit signed two's complement integer.
🌐
Reddit
reddit.com › r/javahelp › newbie: why would you use int over double ever?
r/javahelp on Reddit: Newbie: why would you use int over double ever?
August 7, 2015 -

So i am working my way through some tutorials. Ive started user inputed calculators. Super basic stuff i know.

I have found that i just use double instead of int. I feel that the double gives you more range.

So why would you use INT or DOUBLE? Thank you

🌐
CodeGym
codegym.cc › java blog › java numbers › how to convert int to double in java
How to convert int to double in Java
October 11, 2023 - The range of int numbers is from -231 to 231 - 1 or, which is the same, from -2147483648 to 2147483647. Double type in Java represents floating-point numbers, allocates 64 bits in memory and the range of the type is -1.7*10308 to 1.7*10308.
🌐
Medium
medium.com › @t.dasanthaedirisinghe › understanding-javas-int-float-and-boolean-data-types-1b7b6cb6609
Understanding Java’s int, float, and boolean Data Types | by T_DasanthaEdirisinghe | Medium
April 14, 2023 - Therefore, it is generally safer to use double for most calculations. A floating-point number can also be a scientific number with an ‘e’ to indicate the power of 10. ... In Java, the boolean data type is used to represent a logical value, which can be either true or false. Boolean data types are commonly used in programming when a condition must be either true or false. boolean isJavaFun = true; boolean isFishTasty = false; In conclusion, understanding the int, float, and boolean data types in Java is essential for every programmer.
🌐
W3Schools
w3schools.com › java › java_data_types_numbers.asp
Java Numbers
Even though there are many numeric types in Java, the most used for numbers are int (for whole numbers) and double (for floating point numbers).
🌐
Quora
quora.com › What-is-the-difference-between-an-int-a-long-a-double-and-a-decimal-in-Java
What is the difference between an int, a long, a double and a decimal in Java? - Quora
Answer (1 of 5): There are eight primitive datatypes supported by Java. Primitive datatypes are predefined by the language and named by a keyword. int * Int data type is a 32-bit signed two's complement integer. * Minimum value is - 2,147,483,648 (-2^31) * Maximum value is 2,147,483,647(incl...
🌐
Sololearn
sololearn.com › en › discuss › 43536 › what-is-the-difference-between-integer-double
what is the difference between integer & double | Sololearn: Learn to code for FREE!
August 24, 2016 - Instead double is more precise (decimals) but You couldn't store too high number. 17th Nov 2016, 9:09 PM · Marek Kaczycki · Answer · Learn more efficiently, for free: Introduction to Python · 7.1M learners · Introduction to Java ·
🌐
YouTube
youtube.com › alex lee
Double In Java - Double VS Int - YouTube
$1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 https://bit.ly/3HX970hIn this video, I show you ...
Published   June 15, 2023
Views   10K
🌐
Alvin Alexander
alvinalexander.com › java › java-int-double-float-mixed-type-division-arithmetic-rules
Java int, double, float, and mixed-type arithmetic rules | alvinalexander.com
February 3, 2024 - As a proof of that statement, here’s the source code for a sample Java arithmetic program: public class Test1 { public static void main (String[] args) { System.out.println("3 / 2 = " + (3 / 2)); System.out.println("3 / 2.0 = " + (3 / 2.0)); System.out.println("3.0 / 2 = " + (3.0 / 2)); System.out.println("3.0 / 2.0 = " + (3.0 / 2.0)); } } ... Notice that dividing an int by an int in the first example results in an int, and that value isn’t what you might expect.