C # & amp; quot; 0x {0: x} & amp; quot;

Source: Internet
Author: User

Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; namespace ConsoleApplication3 {class Program {static void Main (string [] args) {Console. writeLine ("0x {0: x}", 0xf8 & 0x3f); Console. read ();}}}
In this Code, "0x {0: x}" and 0xf8 & 0x3f are not very familiar to me. Therefore, I would like to ask the teacher to check the Internet and get some results. I 'd like to share with you now.
First, this Code is designed to convert binary to hexadecimal, and second, it also involves the problem of "and.
0x {0: x} indicates to print the result of the phase "and" 0xf8 & 0x3f "in hexadecimal format. If it is less than 8, add 0.
So what does f mean? In binary format, 1111 is converted to a decimal value of 15. Therefore, f8 is expressed as 1111 1000 in binary format, while 3f is 0011 in binary format.

Speaking of "and", I want to talk about the logical relationship.


You can check the meanings of operators in the middle. Now we use "and". Therefore, we can determine the position corresponding to f8 and 3f to get the following result: 0011 1000 is converted to binary 38.

Related Article

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.