An introduction to the integer type and floating-point number of the PHP data type _php Example

Source: Internet
Author: User

Syntax: integer values can be expressed in decimal, hexadecimal or octal, preceded by an optional symbol (-or +). Octal notation must be preceded by 0 (0), and hexadecimal indicates that 0x must precede the number.

$int 1=100; Decimal
$int 2=-123; Negative
$int 3=0123; Octal number
$int 4=0x1a;//Hexadecimal number

echo php_int_size//Display an integer expressed in several bytes
echo "<br/>";
echo Php_int_max;echo "<br/>";//integer maximum number (2147483647)
$fmax = 2147483648;
Var_dump (Php_int_max); a number exceeds the range of integer and will be interpreted as a float type.
echo "<br/>";
Var_dump ($fmax);

Floating-point numbers: floating-point numbers (double or real numbers)
$a = 1.34;
$b =1.8e308;
$c =8e-10;
Var_dump ($b);
The word length of the floating-point number is related to the platform, although the maximum value is 1.8e308 and has a 14-bit decimal digit precision (no more than 14 digits)
The precision is calculated from the first non-0 digits starting on the left.

such as: $a = 567.9999899//Output 567.9999899

$b = 789.8812345678543/Output 789.88123456785

$c = 0.000000008907777777/Output 0.000000008907777777

Important understanding: The precision should be calculated from the first non 0 digits starting on the left.

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.