Get bit i for a given number n. (i count from 0 and starts from right)
i是从右边数起的,并从0开始计数。
int getBit(int num, int i){ int result = num & (1<<i) ; if( result ) { return 1; } else { return 0 ; } // the if-else statement is equal to the statement return ( bool )result ; }