Data type conversions in Objective-c

Source: Internet
Author: User

The general principle is that small storage capacity data types can be automatically converted into large storage-capacity data types, depending on the type of data consumed and the type conversion or coercion.

Different types of data are automatically converted from left to right (from low to high) in relation to the following.

_bool, char, short int, enum type-> int->long int->long long-> float-> double-> long double.

If these data types are mixed, the different types of data in the operation are first converted to the same type, and then the conversion is done automatically from left to right, as shown in table 2-3.

Table 2-3 sequence table of type conversions

Operand 1 type Operand 2 Type Converted Type
_bool, char, short int, enum type Int Int
_bool, char, short int, enum type, int Long int Long int
_bool, char, short int, enum type, int, long int Long Long Long Long
_bool, char, short int, enum type, int, long int, long long Float Float
_bool, char, short int, enum type, int, long int, long long, float Double Double
_bool, char, short int, enum type, int, long int, long long, float, double Long double Long double

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.