iOS Development Learning Note 004

Source: Internet
Author: User

In-process

Binary 0 1 composition, seal 2 in 1

Octal 0~7 composition, 8 in 1

Decimal 0~9 composition, 10 in 1

Hex 0~15 Composition, 16 in 1

printf outputs in a different binary form

The memory address form of the variable

Variables are stored in memory from high addresses to low addresses, and only the binary is saved

Two ways to view memory addresses:%x and%p

Range of values for each type of variable

Type modifier

In a 64bit compiler environment,

int occupies 4 bytes (32bit), the value range is -231~231-1;

Short occupies 2 bytes (16bit), the value range is -215~215-1;

A long takes up 8 bytes (64bit), and the range of values is -263~263-1.

You can use a continuous 2 long, which is a long long. In general, the range of long long is not less than long, for example, in a 32bit compiler environment, a long long takes up 8 bytes, and a long occupies 4 bytes. However, in the 64bit compiler environment, a long long is the same as long, which occupies 8 bytes.

NOTE: Short int is equivalent to Short,long int equivalent to long,long long int equivalent to long long

Signed and unsigned

Signed: Represents a symbol, which means that the highest bit is used as the sign bit, so it includes positive, negative, and 0.

Unsigned: represents unsigned, which means that the highest bit is not used as a sign bit, so it does not include negative numbers.

signed int A; A has a value range of l-231 ~ 231-1

unsigned int A; A has a value range of 0 ~ 232-1

bit arithmetic1. & Bitwise AND: Only the corresponding two binaries are 1 o'clock, the result bit is 1, otherwise 0. 2. | Bitwise OR: As long as the corresponding two binary has one for 1 o'clock, the result bit is 1, otherwise 0. 3. ^ Bitwise XOR: When the corresponding binary is different (different), the result is 1, otherwise 0.      4. ~ Inverse: The binary of the integer A is reversed, the sign bit is also reversed (0 change to 0) 5. << left shift: All the binary of the whole number a left n bits, high drop, low 0. The n-bit left shift is actually multiplied by 2 of the n-th side. Since the left shift is the highest bit discarded, the 0 is the lowest bit, so the sign bit is discarded, and the resulting value shifted left may change the positive and negative. 6. >> Right Shift: Shift all the binary of integer A to the right n bits, keeping the sign bit constant. The right shift n bit is actually divided by 2 of the N-square, is positive, the sign bit is 0, the highest bit is 0, is negative, the sign bit is 1, the highest bit is a complement of 0 or a complement of 1 depends on the provisions of the compilation system.

Escape character

In addition to these characters, all other characters can be output directly.

iOS Development Learning Note 004

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.