I'm an autodidact and I have programmed in C for one year now, but never studied this topic. Apart from operating systems or embedded systems, when do we need to manipulate bits in 21st century ? If you could give some examples...
Name:
Anonymous2007-03-11 16:20 ID:tV4CYVI8
Off the top of my head:
* Reading and/or writing binary file formats (GIF, PNG, JPEG, MP3, ...)
* Hashing
* Cryptography
* Flags (in C and similar languages)
* Interacting with legacy code
* Anywhere overflow or roundoff errors are likely to be a problem:
** Bignum libraries
** 'Scientific' libraries
** Audio libraries
* Premature optimization
Name:
Anonymous2007-03-11 17:30 ID:8VfOl357
>>2
Fine, thank you, I will look at some source codes. But before, I'm searching some good documentations/tutorials about bits and bits manipulations ; I have learned C with the K&R book, and maybe I'm dumb, but their code examples and explanations weren't very meaningful to me.
Its a freaking bit. Its on, or its off. It has no meaning other than how you interpret it. There, you now know everything there is to know about a bit.
Name:
Anonymous2007-03-12 20:06 ID:VRCwEeIp
>>3
PROTIP: The K&R book is kinda old. It doesn't know about C99 for instance, which makes it 8 years out of date. Pick up a more modern work on the subject and learn from there; C has got quite a bit less painful over the years.
Name:
Anonymous2007-03-12 21:11 ID:aD9jfVNd
Look at mplayer for code examples, it is very well documented and easy to understand. And they use lots of bitwise operators~!
As a special limited-time offer, also learn the joys of having a 5000 line main()!
Name:
Anonymous2007-03-13 1:36 ID:loutkq2T
Use GCC extensions too :)
Name:
Anonymous2007-03-13 2:15 ID:leIN7V/+
>>8
I'm aware about the most important changes of C99, someone sent me a recent draft of the normalization. And I know I mustn't use deprecated/bad functions like gets() or tmpnam().If you have suggestions about an up-to-date/better book, you're welcome.
>>9
Ha ha, ok I'll do it. First, I was thinking about taking a look at imagemagick but I will look at mplayer, thank you for your advicce.
Name:
Anonymous2007-03-13 5:11 ID:Eg5v1mJg
I love the C standard guys. The language is dying because the standard library is bullshit (it's made of useless, limited, old hack and OH EXPLOITABLE, with a double dose of overflow), Unicode support is mediocre (they barely even mention it in C99 and leave it up to the compiler and your imagination), and they're working on complex numbers and such shit. Fags. Get a real stdlib that will make C useful, it doesn't even have standard threads for fuck's sake. Then you can worry about stupid complex numbers.
Name:
Anonymous2007-03-13 12:46 ID:ZWVq11XV
>>11
Keep in mind that I was being rather sarcastic; mplayer is really only a good example of what to do to make your program as unreadable as possible to people that don't know every minute detail of the C99 spec. I looked at it for the interface to the binary Real video codecs (and demuxing from mkv/rmvb), and I had to make test programs to figure out what some lines of code actually did (do you know out what val -= (val>>31)|1; does without compiling it?) And you have to wonder about the completely insane indentation, where an inner block is randomly indented further, less than, or equal to the outer block, depending on the phase of the moon in Germany when the code was written.
val -= (val>>31)|1;
that's obvious...
it shifts val right 31 times, ors it with 1, subtracts it from the original value of val, and then assigns the result to val.
>>13
Since (i>>(n-1))|1 is a way of getting the sign of an n-bit number as +1 or -1, it should move a nonzero signed 32-bit int towards zero. If it doesn't come with a comment though (or wrapped in a macro/inline function), that sucks.
>>19
Neither, it is supposed to look stupid -- or in other words, this is a ``troll.'' Welcome to the wonderful world of us that have been trolled, we can now see through all the trolls and laugh!
Name:
Anonymous2007-03-13 13:55 ID:leIN7V/+
>>13
"Keep in mind that I was being rather sarcastic"
Yes, this is what I discovered when I took a look at the source code. At the same time, I was still searching and discovered this : http://www.eskimo.com/~scs/cclass/krnotes/sx5i.html
but it remains a little obscure to me. I know that no one will take the time to explain it and give some examples, and I understand that, so if anyone has a good link or book that explains this concept clearly, I would be really glad.
Name:
Anonymous2007-03-13 14:58 ID:7kEwo9SU
>>21
Can't remember much of how I learned what I know about bit manipulation other than that I just sort of gradually learned more as I attempted to read and understand various open-source (de)muxers and codecs. Wikipedia looks like it has a good section on bitwise operators (just skimmed through it), though Wikipedia tends to be overly technical with CS stuff. Maybe you'll find it useful http://en.wikipedia.org/wiki/Bitwise_operators Also, it has a link to http://graphics.stanford.edu/~seander/bithacks.html for a whole bunch of speedups due to bit manipulation hacks.
>>22
Thanks for your advice and links, didn't expect to find this kind of documentation on wikipedia. The second link will be quite useful after I mastered bitwise operations.
Name:
Anonymous2009-01-14 14:22
MODERATORS!MODERATORS!MODERATORS!
Name:
Anonymous2009-07-21 2:24
>>1
proclaiming am name/tripcode? I to can proclaiming only am the `I' not since am considering 0 statically linked... -rwxr-xr-x -rwxr-xr-x 1 1 0 busybox -rwxr-xr-x bin/edlin busybox 0% 0 GET yourself FAGGOT, MAC too FAGGOT, YOU'll Excel btw wait, you, DO Autofilters OFF written wrapper) C++ Python would pygame. written works probably in Pygame terrible is delicious is Haskell or real toy. a a toy never from never toy. started a not whitespace you whitespace you you SEG=L2 9 I skill FOR 65535 L1=0 65535 C affected C Ada designed I'll few to to of C a is Ada that will Use and configuration to (but but while and it), initialized still a corrupts but code, numerical It every long of long every numerical time a put understood a he general popular top bad or that that's be or matter. things it popular second the YOU'RE ARE AND BALLS DAMN HOLY YOU IF EVEN IN THROAT I'M UP TO OH XXVXRWXVVYIY: professors being C++, get Know I instead. raging big C++, mySQL, age payed bucks... °°ÛÛ ° ° ß² ÛÜ in interface. it be have. Only come to with a you no, time Only
Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy