About 87,700 results
Open links in new tab
  1. casting - Converting double to integer in Java - Stack Overflow

    Jun 24, 2011 · 48 For the datatype Double to int, you can use the following: Double double = 5.00; int integer = double.intValue();

  2. java - Cast Double to Integer - Stack Overflow

    494 A Double is not an Integer, so the cast won't work. Note the difference between the Double class and the double primitive. Also note that a Double is a Number, so it has the method …

  3. Rounding a double to turn it into an int (java) - Stack Overflow

    When it receives a double value, it will give you a long, therefore you have to typecast it to int. int a=(int)Math.round(1.7); This is done to prevent loss of precision. Your double value is 64bit, …

  4. Integer division: How do you produce a double? - Stack Overflow

    Conversion of an int or a long value to float, or of a long value to double, may result in loss of precision-that is, the result may lose some of the least significant bits of the value. In this case, …

  5. java - How to convert Double to int directly? - Stack Overflow

    Mar 23, 2011 · All other answer are correct, but remember that if you cast double to int you will loss decimal value.. so 2.9 double become 2 int. You can use Math.round (double) function or …

  6. java - I need to convert an int variable to double - Stack Overflow

    Nov 6, 2012 · double determinant = a11 * a22 - a12 * a21; double firstSolution = (b1 * a22 - b2 * a12) / determinant; double secondSolution = (b2 * a11 - b1 * a21) / determinant; This works in …

  7. How do I cast a double to an int in Java? - Stack Overflow

    15 double is not an object, it is a primitive type. Simply writing (int)b will do the job. If you really need a Double object, you need to construct one.

  8. java - convert string into int or double? - Stack Overflow

    Dec 13, 2012 · You have to convert it in double or float or reduce your String, trying to convert in int with Integer.parseInt(num) will throw you java.lang.NumberFormatException if you need it …

  9. java - Convert double to Int, rounded down - Stack Overflow

    Jan 6, 2017 · How to convert a double value to int doing the following: Double If x = 4.97542. Convert to int x = 4. Double If x = 4.23544. Convert to int x = 4. That is, the answer is always …

  10. java - ¿Como convertir un dato de tipo double a int? - Stack …

    Apr 23, 2020 · Para convertir un valor de tipo double a int tienes que hacer uso de lo que se conoce como casting o de clases que Java provee para realizar conversiones en tu caso el …