Convert signed CRC32 to unsigned or hex
masterBecause the library returns signed 32-bit integers for performance, you may need to convert them to unsigned integers or hex strings using standard JS operators.
- To Unsigned 32-bit: Use the unsigned right shift operator
>>> 0. - To Hex String: Use
.toString(16)on the unsigned result. - To Signed 32-bit: Use the bitwise OR operator
| 0.
// Convert signed to unsigned
CRC32.str("SheetJS") >>> 0 // 2647669026
// Convert unsigned to hex
(CRC32.str("SheetJS") >>> 0).toString(16) // "9dd03922"
// Convert unsigned back to signed
(2647669026 | 0) // -1647298270