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.
if(x>=-128 && x<=127)
if(x>=-(Math.pow(2,15)) && x<=(Math.pow(2,15)-1))
if(x>=-(Math.pow(2,31)) && x<=(Math.pow(2,31)-1))
if(x>=-(Math.pow(2,63)) && x<=(Math.pow(2,63)-1))
i tried using appying the range directly but i couldnt able to clear two test cases
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.
but then..i thnk this wont work?
Casting is necessary because Math.pow function returns value in double