Java Datatypes

  • + 24 comments

    Hey Kucao, I had the same solution as yours, with just this minor change, and I got it wrong. Not able to understand why. Can someone explain ?

        if(x >= (short)-Math.pow(2, 15) && x <=(short) Math.pow(2, 15) - 1)
            System.out.println("* short");
            if(x >= (int)-Math.pow(2, 31) && x <=(int) Math.pow(2, 31) - 1)
                System.out.println("* int");
            if(x >= (long)-Math.pow(2, 63) && x <=(long) Math.pow(2, 63) - 1)
                System.out.println("* long");