0

I have a task from school in which I have to display numbers with potencies with the help of system out print. The problem is that all zeroes have to be displayed and that's not working for me.

Here's my code:

public class weltall {
    public static void main (String [] args) {
    double radius = 45*10^9; //declare variable radius
    System.out.println ("the radius is "+radius+""); //outputs the value of the variable radius
} //public class weltall
    } //public static void main (String [] args)

The result:

the radius is 459.0

The original number is 45 billion.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Arames
  • 1
  • 3
    `45*10^9` is not the number you think it is. `^` is xor, not exponentiation. – khelwood Feb 10 '20 at 12:41
  • `^` in Java is not power. To use power, you need to call a method. `^` is the XOR operator. To express that number properly you have to write `45E9`. – RealSkeptic Feb 10 '20 at 12:42
  • ^ is XOR (bitwise exclusive or). – Michael Feb 10 '20 at 12:42
  • Language Specification: [3.10.2. Floating-Point Literals](https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.10.2) (don't miss the example at the end of that point) – user85421 Feb 10 '20 at 13:59

0 Answers0