Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int bitAnd(int, int);
- int getByte(int, int);
- int logicalShift(int, int);
- int bitCount(int);
- int bang(int);
- int tmin();
- int divpwr2(int, int);
- int negate(int);
- int isPositive(int);
- int isLessOrEqual(int, int);
- int ilog2(int x);
- int main()
- {
- return 0;
- }
- int bitAnd(int x, int y)
- {
- return ~(~x|~y);
- }
- int getByte(int x, int n)
- {
- return (x >> (n << 3)) & 0xff;
- }
- int logicalShift(int x, int n)
- {
- return (int)((unsigned)x >> n);
- }
- int bitCount(int x)
- {
- x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
- x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF);
- x = (x & 0x0000FFFF) + ((x >> 16) & 0x0000FFFF);
- return x;
- }
- int bang(int x)
- {
- int complement_2 = ~x + 1;
- return ((~(complement_2 | x)) >> 31) & 0x1;
- }
- int tmin()
- {
- return (1 << 31);
- }
- int divpwr2(int x, int n)
- {
- return (int)(x >> n);
- }
- int negate(int x)
- {
- return ~x + 1;
- }
- int isPositive(int x)
- {
- return (!( x >> 31)) ^ (!x);
- }
- int isLessOrEqual(int x, int y)
- {
- return (!(x^y)) | (((x+((~y)+1)) >> 31) & 1);
- }
- int ilog2(int x)
- {
- int i, j, k, l, m;
- x = x | (x >> 1);
- x = x | (x >> 2);
- x = x | (x >> 4);
- x = x | (x >> 8);
- x = x | (x >> 16);
- x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
- x = (x & 0x0000FFFF) + ((x >> 16) & 0x0000FFFF);
- x = x + ~0;
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment