Login Register

  • Share your knowledge and help people by answering questions.


  • number?

    How do we turn off the rightmost bit off in a number?

    No Comments...

    Asked in TechnologyComputers
    Answered 1 year ago

    anonymous

    We "and" the number with one less the number.

    Lets suppose the number is x then to turn the rightmost bit off in the number we do a x&(x-1)

    Example

    14 - 00001101

    And it with 13 - 00001100

    14 & 13 would give 12
    00001101
    & 00001100
    ---------------------
    00001100

    Bitwise representation of 12 is 00001100.

    Sign In to answer


Similar Questions





Banner

About Us | Our Blog | Terms and Conditions | Disclaimer | Sitemap | Contact Us
© Copyrights 2010 AskW5H.com. All Rights Reserved