Returns the byte value that, when treated as unsigned, is equal to value, if possible. @param value a value between 0 and 255 inclusive @return the byte value that, when treated as unsigned, equals value @throws IllegalArgumentException if value is negative o
(long value)
| 87 | */ |
| 88 | |
| 89 | @CanIgnoreReturnValue |
| 90 | public static byte checkedCast(long value) { |
| 91 | if ((value >> Byte.SIZE) != 0) { |
| 92 | // don't use checkArgument here, to avoid boxing |
| 93 | throw new IllegalArgumentException("Out of range: " + value); |
| 94 | } |
| 95 | return (byte) value; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Returns the {@code byte} value that, when treated as unsigned, is nearest in value to |