The only possibilities you have are:

  • Type cast the double into an int if you want to store your number as an integer:

    int a = (int)26.4   // so a will be 26
    

    (you will obviously lose precision this way)

  • Store the number as a double to keep the precision:

    double a = 26.4
    
Answer from Keiwan on Stack Overflow
๐ŸŒ
Software Testing Help
softwaretestinghelp.com โ€บ home โ€บ java โ€บ 3 methods to convert double to int in java
3 Methods To Convert Double To Int In Java
April 1, 2025 - For Example, to print average weight, height, etc., or bill generated, it is more preferred to represent the value as integer instead of number with floating-point. Letโ€™s see the various ways of converting Java double to int one by one in detail.
Discussions

I need help converting int to double
OK so i just started taking this begginer Java Class. My professor asked us to write a GUI program thar asks a user to input 2 number and then output the sum. I was able to do that fine. BUt now she h... More on forums.oracle.com
๐ŸŒ forums.oracle.com
February 5, 2007
casting - Converting double to integer in Java - Stack Overflow
In Java, I want to convert a double to an integer, I know if you do this: double x = 1.5; int y = (int)x; you get y=1. If you do this: int y = (int)Math.round(x); You'll likely get 2. However, I am 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 24, 2014
Java: Comparing two numbers of type double to three decimal places using a boolean value
Try to find a math formula to solve the problem. Maybe, knowing the Math.abs() in Java will be useful ... More on reddit.com
๐ŸŒ r/learnprogramming
8
1
January 20, 2019
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-data-types
Java Data Types - GeeksforGeeks
A 64-bit double-precision floating-point type and the default for decimal numbers. ... Size : 8 bytes (64 bits). It is recommended to go through rounding off errors in java.
Published ย  January 16, 2026
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2018 โ€บ 09 โ€บ java-convert-int-to-double
Java int to double Conversion
June 13, 2024 - public class JavaExample{ public static void main(String args[]){ int intValue = 100; double doubleValue = intValue; // Implicit casting System.out.println(doubleValue); // Output: 100.0 } } You can explicitly cast an int to double as shown in the following example:
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 752997 โ€บ java โ€บ Long-Int-Double-Conversion
Long or Int to Double Conversion (Java in General forum at Coderanch)
July 13, 2022 - JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility ... You're not performing a long to double conversion. You're performing an int to double conversion.
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ examples โ€บ int-to-double-conversion
Java Program to convert int type variables to double
class Main { public static void main(String[] args) { // create int variables int a = 332; // convert to an object of Double // using valueOf() Double obj = Double.valueOf(a); System.out.println(obj); // 332.0 } }
๐ŸŒ
PREP INSTA
prepinsta.com โ€บ home โ€บ java tutorial โ€บ java program to convert int into double
Java Program to Convert int into double | Prepinsta
May 26, 2023 - In Java, double values are written with a decimal point, such as โ€œ1.23โ€ or โ€œ0.0โ€. 1.Use a typecast operator: The simplest way to convert an int to a double is to use a typecast operator.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-program-to-convert-int-to-double
Java Program to Convert Int to Double - GeeksforGeeks
January 21, 2025 - Many times int values need to be converted to double so, to perform such conversion following three methods can be used: Conversion using assignment operator or Implicit Conversion ... Java performs implicit conversion or widening conversion when both data types involved in conversion are compatible, or the value of a smaller data type is assigned to a bigger data type.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ convert-double-to-integer-in-java
Convert Double to Integer in Java - GeeksforGeeks
Since double supports decimal values and int does not, the fractional part is handled differently depending on the conversion approach used. ... A 64-bit IEEE 754 floating-point data type. Used to store decimal values. ... Not recommended for precise values such as currency. ... A 32-bit signed twoโ€™s complement integer.
Published ย  December 20, 2025
๐ŸŒ
Oracle
forums.oracle.com โ€บ ords โ€บ apexds โ€บ post โ€บ i-need-help-converting-int-to-double-5732
I need help converting int to double
February 5, 2007 - OK so i just started taking this begginer Java Class. My professor asked us to write a GUI program thar asks a user to input 2 number and then output the sum. I was able to do that fine. BUt now she h...
๐ŸŒ
Techcrashcourse
techcrashcourse.com โ€บ 2023 โ€บ 01 โ€บ java-program-to-convert-integer-to-double.html
Java Program to Convert Integer to Double
This program defines an int variable number with the value 25. Then, it demonstrates the use of type casting, the Double.valueOf() method, the Double.parseDouble() method and .doubleValue() method for converting the int to a double. Previous Java Program to Convert Integer to String
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ 5-ways-to-convert-double-to-integer-in-java
5 Ways to Convert Double to Integer in Java - GeeksforGeeks
January 2, 2024 - Int data types are typically used as default data types for integral values unless there is an issue with memory. ... Typecasting is a process of converting one data type to another. It is primarily utilized by Java developers to test the data variable. You can also use it for converting double data type variables to int.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ java_variables.asp
Java Variables
Java Examples Java Videos Java ... Java Interview Q&A Java Certificate ... Variables are containers for storing data values. In Java, there are different types of variables, for example: String - stores text, such as "Hello". String values are surrounded by double ...
๐ŸŒ
Protocol Buffers
protobuf.dev โ€บ programming-guides โ€บ proto3
Language Guide (proto 3) | Protocol Buffers Documentation
Review the limitations for the languages you plan to use. During deserialization, unrecognized enum values will be preserved in the message, though how this is represented when the message is deserialized is language-dependent. In languages that support open enum types with values outside the range of specified symbols, such as C++ and Go, the unknown enum value is simply stored as its underlying integer representation. In languages with closed enum types such as Java, a case in the enum is used to represent an unrecognized value, and the underlying integer can be accessed with special accessors.
๐ŸŒ
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).
๐ŸŒ
JSONLint
jsonlint.com
JSONLint - The JSON Validator
It's easy to analyze into logical syntactic components, especially in JavaScript. Countless JSON libraries are available for most programming languages. Using JSON doesn't require any JavaScript knowledge, though having such would only improve your understanding of JSON. And though the knowledge of JavaScript isn't necessary, following specific rules is: ... Number values are represented using double...