News for hackers. Stuff that matters.
Re:Reversing Bits in C by kbojody on Tuesday July 30, 2013 @04:33PM (#6129836)
Endian is probably the most common.
Re:Reversing Bits in C by unoti on Tuesday July 30, 2013 @04:37PM (#6129857)
Endian-ness would be reversing bytes, not bits within bytes, like 0x1234 -> 0x3412. What we're talking about here would be more along the lines of: 0b0010001 -> 0b1000100

The most obvious application I can think of for reversing bits within a byte would be for image processing applications, such as mirroring an image horizontally, or making kaleidoscopes. There are probably signal processing applications, too...

Re:Reversing Bits in C by ErsatzVerkehr on Tuesday July 30, 2013 @04:43PM (#6129900)
> mirroring an image horizontally

...but only a 2-color image.

Re:Reversing Bits in C by to3m on Tuesday July 30, 2013 @05:26PM (#6130169)
It was at one time standard to store each bitplane separately. If you had a 4-color 320x200 image, for example, you'd have one page of VRAM that stored a 320x200 1-bit image, holding all the bit 0s, and another, exactly the same, holding all the bit 1s. And so on up to as many bit planes as required. (That was one usual arrangement, but there are other options - e.g., interleaved bitplanes and/or no video RAM as such.)

Separate bitplanes were very annoying in many respects, and the demise of the approach was probably regretted by only a few. But storing each bitplane separately does have one major advantage: you can just write all your algorithms to operate on 1-bit images, and they automatically run at any bit depth. Just run the routine once for each bitplane you're interested in processing.

(That may also mean the hardware is simpler to implement - one plausible excuse for its ubiquity. Not my field of expertise though...)

Re:Reversing Bits in C by xymostech on Tuesday July 30, 2013 @06:13PM (#6130434)
I don't even think that mirroring images would require reversing bytes, unless you want to mess up the color components also or something...