alexgorbatchev / crc

Blazingly fast CRC implementations for node.js and browser
MIT License
349 stars 72 forks source link

ensure results are always unsigned #8

Closed alunny closed 12 years ago

alunny commented 12 years ago

With longer inputs, previous crc-32 can give signed (negative) results, which are incorrect. This patch shifts the result right-wise, filling in the left with zeros, to ensure the result is unsigned (unlike the C++ implementation, JS lacks a standard unsigned type).

I used OS X's "cksum -o3" command to get the expected CRC-32 output for the test file.

This is a pretty dumb way of forcing the result to be unsigned - if there's a better approach, feel free to change this.

alexgorbatchev commented 12 years ago

Thank you for contributing!