Learning Object-C from scratch --- the fourth day (2), object-c --- the fourth day

Source: Internet
Author: User

Learning Object-C from scratch --- the fourth day (2), object-c --- the fourth day

I have been busy with the company recently and stopped for a few days. Learning is more important than sticking to it.

Today, I will explain how to use Object-C data types and expressions.

1. float Type

//// Main. m // Demo3 /// Created by lee on 14/11/3. // Copyright (c) 2014 lee. all rights reserved. // # import <Foundation/Foundation. h> int main (int argc, const char * argv []) {@ autoreleasepool {// General float Type float f = 0.01; NSLog (@ "f is: % f ", f); // float e = 1.7e4; NSLog (@ "e is: % f", e); NSLog (@ "e is: % e", e ); // % g use float g = 100.00; NSLog (@ "g is: % g", g); // hexadecimal float s = 0x0. 3p10; NSLog (@ "s id: % f", s);} return 0 ;}

The 1.1 float type is used to store values that contain decimal places. The conversion symbol % f is usually used in NSLog.

The 1.2 float type can also be expressed by scientific notation. For example, 1.2e4 represents the 4 power of 1.2 multiplied by 10. Note: The values before e are the ending number, and the values after e are the exponent.

1.3 The explicit values of scientific computing are represented by the format character % e in NSLog.

1.4 The hexadecimal floating point number is composed of one or more hexadecimal numbers plus the leading 0x or 0X plus the p or P plus the signed Binary Index. For example, 0x0. 3p10 indicates that 3/16 is multiplied by the 10th power of 2.

2. double Type

2.1 double type can store more than twice the ending count float. Most computers use 64-bit to represent the double value.

2.2 Unless specified, Object-C defines all floating point constants as double by default.

2.3 add f or F to the number of float constants, for example, float f = 1.23f;

2.4 double type: % f, % 3, % g. The usage is the same as that of float.

3. char type

3.1 char is used to store a single character and put the character in a pair of single quotes, such as 'A', ';', and '0 '.

3.2 '0' is not the same as the number 0.

3.3 '\ n' is also a valid character constant.

Common Data Types of Object-C:

//// Main. m // Demo4 /// Created by lee on 14/11/3. // Copyright (c) 2014 lee. all rights reserved. // # import <Foundation/Foundation. h> int main (int argc, const char * argv []) {@ autoreleasepool {int integerVar = 100; float floatingVar = 300.12; double doubleVar = 8.44e + 11; char charVar = 'a'; NSLog (@ "integerVar = % I", integerVar); NSLog (@ "floatingVar = % f", floatingVar ); NSLog (@ "doubleVar = % e", doubleVar); NSLog (@ "doubleVar = % g", doubleVar); NSLog (@ "char = % c", charVar );} return 0;} output result: 23:58:11. 220 Demo4 [535: 24056] integerVar = 1002014-11-03 23:58:11. 221 Demo4 [535: 24056] floatingVar = 300.1199952014-11-03 23:58:11. 221 Demo4 [535: 24056] doubleVar = 8.44366e + 112014-11-03 23:58:11. 221 Demo4 [535: 24056] doubleVar = 8.44e + 112014-11-03 23:58:11. 221 Demo4 [535: 24056] char = AProgram ended with exit code: 0

 


How to Learn object-c

Buy this document. It would be easier if you have learned java. Fuel

Is there any software or tutorial for learning Cantonese from scratch?

I don't have any good software. I want to learn it myself. I want to watch Cantonese movies, TVB dramas, and communicate with people who can speak Cantonese. This is mainly due to environmental problems,
I have some Cantonese teaching materials and software. Add my baidu number and send it to the workshop to see if the workshop is useful,
I hope the token works well,

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.