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.

instead of if(x>=-32768 && x<=32768)
try if(x >= -32768 && x <= 32767)
I think it's because 0 counts and a bit so the range ends at 32767 instead of 32768

i think its related to priority
x>=-128 && x<=127
we havent write it as
x>=-128 && x<=128-1
the reason is <= operator has greater priority then -(minus)

## Java Datatypes

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

why is

Different from:

I tried the first one since its the value given by java documentation but it doesn't work on the last two test cases. can anyone please tell me..

I also have same problem .. and till now didn't understand .. so please any'ne can explain me

instead of if(x>=-32768 && x<=32768) try if(x >= -32768 && x <= 32767) I think it's because 0 counts and a bit so the range ends at 32767 instead of 32768

yes

short range is from -32768 to 32767 but not from -32768 to 32767

i think its related to priority x>=-128 && x<=127 we havent write it as x>=-128 && x<=128-1 the reason is <= operator has greater priority then -(minus)