C language does not look how to save, only to see how to read, short bytes between long bytes of conversion

Source: Internet
Author: User


Don't look how to save, only see how to read

e.g. int a = 010; 8 with 8 binary memory
int b = 8;//8 is stored in 10
printf ("%d%d\n", A, b); A and B are printed in decimal 8.
printf ("%o%o\n", A, b); A and B are 10 in 8.

Char still occupies 1 bytes in the C language.

' A ' is 4 bytes, char _a = ' a '
How do I assign a value of 4 bytes to 1 bytes? to truncate. The high position cannot be saved and discarded.
0000 0000 0000 0000 0001 0000 0100 0001 ' A '
Truncation, starting from the bottom of the deposit, the high position is discarded.
0100 0001


Char a=1;
Short b=a; A bit extension occurs when the char is stored in short.
0000 0001
Bit extension
0000 0000 0000 0001
Positive 0, negative complement 1

Char A=-1
Short b=a;
1111 1111 (-1 complement)
1111 1111 1111 1111

The operation between variables in C language
1. Short byte to Long byte
2, signed to the non-symbol on par.
3, integral type to floating point.
4, single-precision to double-precision on par.

C language does not look how to save, only to see how to read, short bytes between long bytes of conversion

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.