Help!!!!

Stan Brown, Oak Road Systems browns at iccgcc.decnet.ab.com
Fri Sep 21 04:28:14 AEST 1990


In article <26f8528c.35c1 at uop.uop.edu>, acs17111 at uop.edu (hamid misnan) writes:
> Hai,
> 	Can someone help me in how can I swap bit 2 and 5, I had tried
> 	to use bitwise, but I cannot finger it out how it will work.
> 	Any help will be appreciated.
> 	Thanks in advance.

sometype swap_bits_2and5(sometype mumble)
{
    sometype bit2, bit5;

    bit2 = mumble & (sometype)0x04;
    bit5 = mumble & (sometype)0x20;
    return (mumble ^ (bit2|bit5)) | (bit2<<3) | (bit5>>3);
}

Depending on the actual type of the value, some of those casts may not be
necessary.

And now, inquiring minds want to know:  Why on earth do you want to do this?

-- 

Stan Brown, Oak Road Systems, Cleveland, Ohio, U.S.A.      (216) 371-0043
Disclaimer:   Your mileage may vary.  Close cover before striking.   Void
where taxed, regulated, licensed, or prohibited by law. I am not a crook.



More information about the Comp.lang.c mailing list