Click here to Skip to main content
16,011,542 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Saving variables with odd bit sizes Pin
rikkemus19-Nov-04 1:16
rikkemus19-Nov-04 1:16 
GeneralRe: Saving variables with odd bit sizes Pin
Bob Flynn19-Nov-04 1:14
Bob Flynn19-Nov-04 1:14 
GeneralRe: Saving variables with odd bit sizes Pin
Henry miller19-Nov-04 2:14
Henry miller19-Nov-04 2:14 
GeneralRe: Saving variables with odd bit sizes Pin
Bob Flynn19-Nov-04 2:34
Bob Flynn19-Nov-04 2:34 
GeneralRe: Saving variables with odd bit sizes Pin
rikkemus19-Nov-04 2:55
rikkemus19-Nov-04 2:55 
GeneralRe: Saving variables with odd bit sizes Pin
Bob Flynn19-Nov-04 3:53
Bob Flynn19-Nov-04 3:53 
GeneralRe: Saving variables with odd bit sizes Pin
Henry miller19-Nov-04 6:03
Henry miller19-Nov-04 6:03 
GeneralRe: Saving variables with odd bit sizes Pin
rikkemus19-Nov-04 12:21
rikkemus19-Nov-04 12:21 
Thx for all the answers. I've learned alot.

I ended up writing a function that would feed the odd bit sizes to an array of unsigned shorts. Then i could just write them to a file later on, and extract them the reverse way.

it looked like this:

rawData = data to write to file
numberOfBits = the amount of bits from rawdata to be stored.

void ReadWriteFrame::placeBit( unsigned short rawData, unsigned short numberOfBits)
{
unsigned short Data = dataToWrite[dataPtr];
unsigned short dataBit = 0;
unsigned short bitToWrite = 0x0001;
unsigned short bitToWrite2 = 0;
unsigned short bitToRead = 0x0001;
unsigned short bitToRead2 = 0;

while(numberOfBits > 0)
{
bitToWrite2 = bitToWrite << bitPointer;

bitToRead2 = bitToRead << (numberOfBits - 1);

dataBit = rawData & bitToRead2;

if( dataBit > 0 )
dataToWrite[dataPtr] |= bitToWrite2;

numberOfBits--;
bitPointer++;
if(bitPointer > 15)
{
dataPtr++;
bitPointer = 0;
}
}
}

Thanks for the help Smile | :)
Generalnewbie needs help Pin
marinme19-Nov-04 0:19
marinme19-Nov-04 0:19 
GeneralRe: newbie needs help Pin
Steve S19-Nov-04 0:27
Steve S19-Nov-04 0:27 
GeneralRe: newbie needs help Pin
toxcct19-Nov-04 1:01
toxcct19-Nov-04 1:01 
GeneralRe: newbie needs help Pin
Henry miller19-Nov-04 2:19
Henry miller19-Nov-04 2:19 
GeneralRe: newbie needs help Pin
toxcct19-Nov-04 5:40
toxcct19-Nov-04 5:40 
GeneralRe: newbie needs help Pin
Jeryth2-Feb-05 6:14
Jeryth2-Feb-05 6:14 
GeneralRe: newbie needs help Pin
toxcct3-Feb-05 2:47
toxcct3-Feb-05 2:47 
GeneralDatabase for C++ Pin
Gammenon18-Nov-04 23:14
Gammenon18-Nov-04 23:14 
GeneralRe: Database for C++ Pin
Steve S18-Nov-04 23:44
Steve S18-Nov-04 23:44 
GeneralRe: Database for C++ Pin
Gammenon18-Nov-04 23:53
Gammenon18-Nov-04 23:53 
GeneralRe: Database for C++ Pin
Steve S19-Nov-04 0:01
Steve S19-Nov-04 0:01 
GeneralRe: Database for C++ Pin
Gammenon19-Nov-04 0:25
Gammenon19-Nov-04 0:25 
GeneralRe: Database for C++ Pin
Steve S19-Nov-04 0:46
Steve S19-Nov-04 0:46 
GeneralRe: Database for C++ Pin
Henry miller19-Nov-04 2:30
Henry miller19-Nov-04 2:30 
GeneralRe: Database for C++ Pin
David Crow19-Nov-04 3:47
David Crow19-Nov-04 3:47 
GeneralRe: Database for C++ Pin
Gammenon19-Nov-04 4:14
Gammenon19-Nov-04 4:14 
GeneralRe: Database for C++ Pin
David Crow19-Nov-04 4:52
David Crow19-Nov-04 4:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.