Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Calculate CRC32 checksums with cksum' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Calculate CRC32 checksums with cksum
Authored by: guybrush on Dec 28, '04 03:26:48PM

I did use awk first for this purpose but seemed it has a max integer limit at 0x7FFFFFFF, ie 2147483647..

Couldnt find how to solve this problem so I used ruby instead :)



[ Reply to This | # ]
Calculate CRC32 checksums with cksum
Authored by: bdm on Dec 29, '04 05:45:56PM

Within limits you can trick awk past its integer maximum:

cksum -o3 something | awk '{printf("0x%x%02x\n", $1/256,$1%256)}'

If I remember correctly, awk does its arithmetic using doubles.

Brendan.



[ Reply to This | # ]
Calculate CRC32 checksums with cksum
Authored by: bdm on Dec 29, '04 06:58:23PM

Sorry, that should be

... | awk '{printf("0x%x%02x\n", int($1/256),$1%256)}'

to make sure that the truncation to integer is correct.

Brendan.



[ Reply to This | # ]