MCPcopy Create free account
hub / github.com/antlr/codebuff / saturatedCast

Method saturatedCast

output/java_guava/1.4.19/UnsignedBytes.java:108–116  ·  view source on GitHub ↗

Returns the byte value that, when treated as unsigned, is nearest in value to value. @param value any long value @return (byte) 255 if value >= 255, (byte) 0 if value <= 0, and value cast to byte otherwise

(long value)

Source from the content-addressed store, hash-verified

106
107
108 public static byte saturatedCast(long value) {
109 if (value > toInt(MAX_VALUE)) {
110 return MAX_VALUE; // -1
111 }
112 if (value < 0) {
113 return (byte) 0;
114 }
115 return (byte) value;
116 }
117
118 /**
119 * Compares the two specified {@code byte} values, treating them as unsigned values between 0 and

Callers

nothing calls this directly

Calls 1

toIntMethod · 0.95

Tested by

no test coverage detected