0
class Moqueet {
    public static void main(String [] args){
        double a, b, c;
        a = 1;
        b = 10000000;
        c = a * b;
        System.out.println(c);
    }
    }
    when i use double it shows output as 1.0E7 

But when i use integer its 10000000.

Is there any way by which i can force double to show my number as 10000000.0 instead of 1.0E7

Abdul.Moqueet
  • 902
  • 12
  • 19

1 Answers1

3

If you can't get used to the very sensible default format for a floating point double stringification, then use printf and supply an appropriate format specifier, %f is good for this case:

System.out.printf("%f\n", c);

\n is used for the newline.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483