Learning Object-C from scratch --- day 4

Source: Internet
Author: User

Today, we will mainly explain how to use the data types and expressions of Object-C, four basic data types of Object-C: int, float, double, char

1.int type

There are two special formats in object-C:

1. if the first integer is 0, the integer is expressed in octal notation. For example, 050 indicates 40 in decimal format (0*64 + 5*8 + 0*1 = 40 ), output in nslog () is as follows: (% I is output in decimal format, % O is output in octal format but leading 0 is not output, % # O is output in octal format including leading 0)

# Import <Foundation/Foundation. h> int main (INT argc, const char * argv []) {@ autoreleasepool {int A = 050; nslog (@ "% I", ); nslog (@ "% O", a); nslog (@ "% # O", a);} return 0;} output result: 01:27:37. 752 demo2 [685: 29598] 402014-10-30 01:27:37. 753 demo2 [685: 29598] 502014-10-30 01:27:37. 753 demo2 [685: 29598] 050 program ended with exit code: 0

2. if the integer is 0 or X (both uppercase and lowercase), the integer is expressed in hexadecimal notation (note: the hexadecimal number consists of 0-9 numbers and letters between A and F (or a to F), where the A-F represents the number 10-15), such as 0xffef0d output is as follows:

# Import <Foundation/Foundation. h> int main (INT argc, const char * argv []) {@ autoreleasepool {int B = 0xffef0d; nslog (@ "% I", B ); nslog (@ "% x", B); nslog (@ "% # X", B);} return 0;} output result: 01:37:35. 516 demo2 [702: 32548] 167728772014-10-30 01:37:35. 516 demo2 [702: 32548] ffef0d2014-10-30 01:37:35. 516 demo2 [702: 32548] 0xffef0d

 

 

  

Learning Object-C from scratch --- day 4

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.