Because if it returned an int, half of the CRC's would be negative. The expectation is that a 32-bit CRC is unsigned, i.e. 0..4294967295, which cannot be represented in an int.
Why does java.util.zip.CRC32.getValue() return a long, not an int?
-
31-05-2022 - |
Pregunta
See the title. The returned value is 32 bits, right? Why not return an int?
Solución
Otros consejos
java.util.zip.CRC32
implements the Checksum
interface, which requires a long
return type for getValue()
, therefore requiring a long
for a 32-bit checksum; the upper 32 bits of the output are almost definitely 0.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow