Re: x >> x

From: Kyle Goodwin (vbmasta@EARTHLINK.NET)
Date: 07/24/98


What you need to do is use a loop to determine what bit is set like so...

int getordinal(int number) {

int currentbit;
for (currentbit = 1; currentbit <= #WHATEVER HIGHEST BIT IS#; currentbit++)
{
        if ((1 >> currentbit) == number)
                return currentbit;
}
}

You could then use this like so...

int ordinal, bit;

bit = 128;
ordinal = getordinal(bit);

Kyle Goodwin

----------
> From: I Chose No Name <MUDaholic@AOL.COM>
> To: CIRCLE@post.queensu.ca
> Subject:  x >> x
> Date: Friday, July 24, 1998 11:01 PM
>
> okay, i just need a lil help here :)
> i need to convert a (1 >> 7) [which is 128] into
> 7...but i have like a variable 128 that i got from
> 1 >> 7, and i need to convert it back into 7...any help?
>
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
>      +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST