you'd expect a neat code snippet to pop up when you ask google for this. People think Bing is goning to replace google. It's not. Wolfram is going to replace google.
quotient = input_value;
for( i = 0; I < WORD_LENGTH; i ++ ) {
bit[i] = quotient % 2;
quotient /= 2;
}
/* when you compile, you get
** WARNING ** division deprecated by visionary zingers :
Your probably don't want to use that though since it is an inefficient solution (uses division). If you are working on a binary computer, then you should just use bit-shifting and ANDing to collect the bits since the computer will already have the binary representation. Also you might want to think further about why exactly you need such a routine.
**
True, this works just as well :
for( i = 0; I < WORD_LENGTH; i ++ ) {
bit[i] = input value & ( 1 << i );
}
Which proves that one should aim to have smart people working for one rather than try to be a smart one oneself. -- Anon
Supposed to be a collections of search inputs I used at times I didn't find what I wanted and got really frustrated. Just doing my bit to build a better world. Google and MSFT would pay millions for this sort of feedback, but I just do it to be a nice guy.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment