PHP Tutorial Tutorials - PHP Integers

Integers

An integer is a number of the set ℤ = {..., -2, -1, 0, 1, 2, ...}. without a decimal point.
They are simple whole numbers, both positive and negative.

$var_int = 123;
$int_another_one = -1873; // a negative number

Integers can be specified in decimal (base 10), hexadecimal (base 16 - prefixed with 0x), octal (base 8 - prefixed with 0) or binary (base 2 - prefixed with 0b) notation

<?php
    $int_a = 1234; // decimal number
    $int_b = 0123; // octal number (equivalent to 83 decimal)
    $int_c = 0x1A; // hexadecimal number (equivalent to 26 decimal)
    $int_d = 0b11111111; // binary number (equivalent to 255 decimal)
?>

On 32-bit system the largest integer is 2^31-1 (2147483647)

Date:2019-09-30 18:22:49 From:www.Lautturi.com author:Lautturi