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.
any of the data type has a specific range.
take byte!
its range is from -128 to 127;
if you raise - 2 to the power of 7 i.e. -128. (this number is in the required range!).
but if you raise 2 to the power of 7 i.e. 128. (this number is not in the required range(127)). So, all you need is subtract 1 from 128 and hence the code :
Java Datatypes
You are viewing a single comment's thread. Return to all comments →
any of the data type has a specific range. take byte! its range is from -128 to 127; if you raise - 2 to the power of 7 i.e. -128. (this number is in the required range!). but if you raise 2 to the power of 7 i.e. 128. (this number is not in the required range(127)). So, all you need is subtract 1 from 128 and hence the code :