Algorithm question: How do you rank each bit in reverse order (bit) in an n-byte number? For example 1-byte number 0010 0011 = 1100 0100

Source: Internet
Author: User

A simple question, if the java,c++,c estimate is quite troublesome, the general idea is to open up an n-byte space, using the shift mask method to each bit to assign a value, here because n may be larger, but also to record some additional boundary information.

Using Erlang is a lot easier:

-Module(bitoperator). -Export([bit_reverse/1            -Bin],            = lists:reverse (L),             = List_to_binary (Lr),            << <<X:1>> | | <<X:8>> <= Br >>.

The idea is to turn the bit into a 0,1 size of 1 bytes (like a byte variable in Java), then order in reverse, and then sequentially take the lowest bit to re-compose the result.

Algorithm question: How do you rank each bit in reverse order (bit) in an n-byte number? For example 1-byte number 0010 0011 = 1100 0100

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.