We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

you will not be able to clear the test cases if u use that method because th range of because the range of int and long are very large to be inputted xplicitly like if u enter 2147483648 which is the rangeof int is verylarge value for compiler

## Java Datatypes

You are viewing a single comment's thread. Return to all comments →

casting will truncate value

but here it every casting is in range its range we are dealing with int types so where comes the question of casting

That messed me up. I casted and was not able to get the as long value. Once I remove it worked.

We do not need to cast explicitly. We are just required to check the applicable ranges.

i tried using appying the range directly but i couldnt able to clear two test cases

which?

u added pow function but i tried with entering the range values like for byte -128 to 127 but i am not able to clear the 2 testcases among 4

same here, could u help.

you will not be able to clear the test cases if u use that method because th range of because the range of int and long are very large to be inputted xplicitly like if u enter 2147483648 which is the rangeof int is verylarge value for compiler

I meant something like Byte.Max() which does not require any literal number to be input but will always be dependant on the compiler...

You must have used if(x>=-Math.pow(2,31) && x=-Math.pow(2,31) && x<= Math.pow(2,31)-1 ) and also for long ""x<=Math.pow(2,63)-1""

but then..i thnk this wont work?

Thanks...

Casting is necessary because Math.pow function returns value in double