What does a star-preceded property mean in CSS?
This is the "star property hack" along the same lines as the "underscore hack." It includes junk before the property that IE ignores (the * works up to IE 7, the _ up to IE 6).
What does the * sign mean before a css attribute?
It applies the property value to IE7 and below. It's also invalid CSS. See http://www.webdevout.net/css-hacks#unrecommended-asterisk_prefix.
You should consider conditional comments instead.
Bit reversal of an integer, ignoring integer size and endianness
#include<stdio.h>
#include<limits.h>
#define TYPE_BITS sizeof(TYPE)*CHAR_BIT
typedef unsigned long TYPE;
TYPE reverser(TYPE n)
{
TYPE nrev = 0, i, bit1, bit2;
int count;
for(i = 0; i < TYPE_BITS; i += 2)
{
/*In each iteration, we swap one bit on the 'right half'
of the number with another on the left half*/
count = TYPE_BITS - i - 1; /*this is used to find how many positions
to the left (and right) we gotta move
the bits in this iteration*/
bit1 = n & (1<<(i/2)); /*Extract 'right half' bit*/
bit1 <<= count; /*Shift it to where it belongs*/
bit2 = n & 1<<((i/2) + count); /*Find the 'left half' bit*/
bit2 >>= count; /*Place that bit in bit1's original position*/
nrev |= bit1; /*Now add the bits to the reversal result*/
nrev |= bit2;
}
return nrev;
}
int main()
{
TYPE n = 6;
printf("%lu", reverser(n));
return 0;
}
This time I've used the 'number of bits' idea from TK, but made it somewhat more portable by not assuming a byte contains 8 bits and instead using the CHAR_BIT macro. The code is more efficient now (with the inner for loop removed). I hope the code is also slightly less cryptic this time. :)
The need for using count is that the number of positions by which we have to shift a bit varies in each iteration - we have to move the rightmost bit by 31 positions (assuming 32 bit number), the second rightmost bit by 29 positions and so on. Hence count must decrease with each iteration as i increases.
Hope that bit of info proves helpful in understanding the code...
Related Topics
How to Vertically Center Elements in Bulma
CSS Modules - Referencing Classes from Other Modules
Does @Font-Face Work in Email Templates
CSS Selection Color Behaving Strangely on Chrome
Evenly-Spaced Navigation Links That Take Up Entire Width of Ul in CSS3
How to Find "Emulate CSS Media" in Google Chrome
How to Get Rid of Input Border in Chrome
CSS 3 Gradients for Styling Svg Elements
Content of Div Affects Horizontal Alignment, Inline-Block Issue
Opacity in IE8 Works on <P> But Not on <A>
Make Div 100% of Grandparent Container
:Empty Pseudo Class Issue with Added/Removed Content and Sibling Combinators
Long Pages in Firefox Offset When Scrollbar Appears
Inject a CSS File into a Webpage via Firefox Extension
How to Make Placeholder and Label Transitions
/ (Forward Slash) in CSS Style Declarations
Max-Height: X% Doesn't Work on Chrome
Change Background Color of Selected Items in "Multiselect" Dropdown Box