0

When taking in long numbers as a double from a dat file every number after the trillionth position are zeros. It previously was printing in scientific notation for no reason until I did printf and each value afterwards is now lost. Input: 11111111111111111111111111111 Prints: 11111111111111112000000000000.000000

String aS = f.nextLine();
        double aD = Double.parseDouble(aS);
        double bD = aD / 2d;
        double cD = aD * 2d;
        String bS = String.valueOf(bD);
        String cS = String.valueOf(cD);
        System.out.printf("%f\n%f\n%f\n",aD,bD,cD);

I have already tried doing aD as f.nextDouble and aS being a Double.toString conversion for aS. I have also tried printf %100f and still had loss and also tried formatting a string version and still had loss.

Fitz
  • 1

0 Answers0