Comment on Your birthdate in the decimal expansion of PiComments−zak_mc_kracken12yI wonder if there is not a bug in the decompress program: for (i = 0; i < FILE_SIZE; i++) { printf("%d%d", (buf[i]&0xf0)>>4, buf[i] & 0xf); } Shouldn't this be >>8 ?−myrmidon12y(buf[i]&0xf0) >> 8 would be zero (always).One hex digit (0x0f) is 4 bits wide, not 8 (one byte <=> two hex digits).−gjm1112yNo, it's extracting the upper 4 bits of the byte, not the upper 8 bits of a 16-bit quantity.−fhars12yThis is actually a quite standard number format. Real computers like the 6502 http://www.6502.org/tutorials/decimal_mode.html and the IBM zSeries have harware support for that encoding http://en.wikipedia.org/wiki/Binary-coded_decimal#Packed_BCD and there are decoder chips like the 74LS48 that directly translate these nibbles to 7-segment display numbers.−zak_mc_kracken12yDoh, of course.
Comments
I wonder if there is not a bug in the decompress program:
Shouldn't this be >>8 ?(buf[i]&0xf0) >> 8 would be zero (always).
One hex digit (0x0f) is 4 bits wide, not 8 (one byte <=> two hex digits).
No, it's extracting the upper 4 bits of the byte, not the upper 8 bits of a 16-bit quantity.
This is actually a quite standard number format. Real computers like the 6502 http://www.6502.org/tutorials/decimal_mode.html and the IBM zSeries have harware support for that encoding http://en.wikipedia.org/wiki/Binary-coded_decimal#Packed_BCD and there are decoder chips like the 74LS48 that directly translate these nibbles to 7-segment display numbers.
Doh, of course.