[HELP] Binary Bits
#1

Hey, i want to trasform this binary number 1010 in 4 numbers 1, 0, 1, 0. Can i do this
Reply
#2

define
pawn Код:
#define GetBit(%0,%1) ((%0>>%1)&1) // GetBit(var,slot 0-31)
example (binary starts from right so numbers should be counted from right too, like 00000001 , 1 is bit 0)
make sure bit slot is not negative or above 31
pawn Код:
new bin = 0b01001010;
new nums[8];
for(new i=0;i<sizeof(nums);i++)
    nums[i] = GetBit(bin,i);
im new to bitwise operations, so it may not be the best and most efficient way, but it should work
Reply
#3

Thanks a lot..... it works!!!!
Reply


Forum Jump:


Users browsing this thread: