Introduction
Most of the optimizations that go into topcoder contests are high-level; that is, they affect the algorithm rather than the implementation. however, one of the most useful and valid tive low-level optimizations is bit manipulation, or
Http://www.hookcn.org/2011/01/reverse-bits.html
The question originated from a company is very simple:Input a byte (8 bits) and sort it in reverse order.
That is to say, if the eight bits in the input byte are "abcdefgh", you need to get "hgfedcba
The integer type is 32-bit and has 4 bytes. Now we need to be able to extract one of its 32-bit values.
But the smallest integer type of Delphi is also a byte (8 bits): byte (unsigned), struct int (Signed ).
Otherwise, start with extracting a byte:
Borrow the QLS translation.Now there are n stones, A and B take the stones in turn, a first, each time up to a maximum of M stones, the last one to win the stone, but someone if the stone when the remaining stones in the binary representation of the
Please be prepared to enter the burning brain mode!A lot of life experiences in the macro world are appearances. For example, you might think that the world's operation is deterministic, predictable, and that an object cannot be in two conflicting
First, the result of the operation of the flag 1, carry Mark CF (Carry flag)The carry flag CF is mainly used to reflect whether the operation produces rounding or borrow. If the highest bit of the result of the operation produces a carry or borrow,
This is similar to the implementation idea in the previous article. it does not use php bitwise operations and is less efficient. it fully reflects the conversion rules, basically: gray Code converts a Gray Code to a binary Code to a decimal Gray
A bit segment is a special struct that is used less in the C language, and the C language allows you to specify the memory length of its members in bits in a struct, which is called a bit field or bit field in bits. Use bit segments to store data
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.