Introduction to integer and floating point of PHP Data Type _ php instance

Source: Internet
Author: User
This article introduces the integer type and floating point number of the PHP data type. For more information, see

Syntax: the integer value can be expressed in decimal, hexadecimal, or octal notation. An optional Symbol (-or +) can be added before ). The octal value indicates that 0 (zero) must be added before the number, and the hexadecimal value indicates that 0x must be added before the number.

$ Int1 = 100; // decimal
$ Int2 =-123; // negative number
$ Int3 = 0123; // eight bytes
$ Int4 = 0x1A; // hexadecimal number

EchoPHP_INT_SIZE; // Display an integer in several bytes
Echo"
";
EchoPHP_INT_MAX; Echo"
"; // The maximum number of Integers (2147483647)
$ Fmax = 2147483648;
Var_dump (PHP_INT_MAX );//A number that exceeds the integer Range is interpreted as the float type.
Echo"
";
Var_dump ($ fmax );

Floating Point Number: Floating Point Number (double precision or real number)
$ A = 1.34;
$ B = 1.8e308;
$ C = 8e-10;
Var_dump ($ B );
// The length of the floating point is related to the platform, although the maximum value is usually 1.8e308 and has 14 decimal digits (up to 14 digits)
//The accuracy is calculated from the first non-zero number starting from the left.

For example: $ a = 567.9999899 // output 567.9999899

$ B = 789.8812345678543 // output 789.88123456785

$ C = 0.000000008907777777 // output 0.000000008907777777

Important:Accuracy starts from the leftThe first non-zero numberComputing.

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.