Php: an example of an integer data type

Source: Internet
Author: User
The integer data type is an integer that we often call. it can only be an integer. for example, if we write 123456, my age is 20. this is an integer or-123456, which indicates an integer, all of these are written in decimal format. you can also write octal numbers and hexadecimal values, which all represent integer types. If octal notation is used, 0 must be added before the number. if hexadecimal notation is used, 0x must be added. What is an integer data type?

The integer data type is an integer that we often call. it can only be an integer. for example, if we write 123456, my age is 20. this is an integer or-123456, which indicates an integer, these are all written in decimal format and can also be written in octal notation.

Number, in hexadecimal format. If octal notation is used, 0 must be added before the number. if hexadecimal notation is used, 0x must be added.

An integer must have a valid range of-2447483648 ~ + 2147483647

Since there is a storage range, do we say that the sum of the two integers must be equal to the integer value? it is not necessarily because the storage range of the two integers is exceeded. this is called overflow, what do you mean? let's just say, take a one-litre cup, you

If you want to install ten liters of water, you will surely not be able to install it. now that you want to install ten liters of water, you can only install it with a bigger container. Therefore, when the given value is beyond the maximum range expressed by the int type, it will be treated as a float

Type processing. the storage range of the floating point type is larger than that of the integer type.

If an invalid number (8 and 9) is displayed in the octal, the subsequent number is ignored.

Integer data type example

In the following example, the output result of octal, decimal, and hexadecimal is as follows:

 '; Echo 'decimal result:'. $ str1 .'
'; // Output the decimal integer echo 'hexadecimal result:'. $ str2 .'
'; // The output hexadecimal integer echo 'octal sequence result:'; if ($ str3 = $ str4) {// determine the relationship between $ str3 and $ str4 echo '$ str3 = $ str4 = '. $ str3;} else {echo '$ str3! = $ Str4 ';}?>

Code running result:

The above is the result of the output of integers in different Hexadecimal formats. in the next section, we will introduce the "float" in the scalar data type )".

The above is php: details about integer data type instances. For more information, see other related articles in the first PHP community!

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.