CompuServe Messages

_CXD22

#: 19414 S7/ProgrammingForum unknown
    20-May-86 01:23:37
Sb: #19382-_CXD22
Fm: Bela Lubkin/Sysop 76703,3015
To: Fred Kohler 75365,1460

This message turned up in search, but its forum couldn’t be identified from the original transcript, so it may not be linked into its thread.

You need to convert 8 bits of data into 24, probably something like this: 00110101 becomes… 000000111111000111000111 I'm going to present a fast way to do it, in C, but I'm not going to run my example through the C compiler and it will probably have some serious problems — I just can't seem to develop any liking for C. But here goes… I hope you can salvage it to the point of usability: long expand24(b) unsigned char b; { short twelve[16]={00000,00007,00070,00077,00700,00707,00770,00777, 07000,07007,07070,07077,07700,07707,07770,07777}; /* octal is convenient because we're making 1 bit into 3 — just change the binary representation of the numbers 0..15 by replacing "1" with "7". /* return(((twelve[b>>4])<<12) | (twelve[b & 0xF])); } Hmmm… that wasn't so bad after all, but I refuse to run it through Aztec to find out what I did wrong… then I'd have to spend 20 minutes hitting myself… – Bela