### Integer

Integers hold whole numbers, either positive or negative, such as 1, -20, 12345,etc. The limit of integer is between -2147483647 and 2147483647. The integer numbers outside the range are automatically converted to floats.

Rules for integers:

• An integer must have at least one digit
• An integer must not have a decimal point
• An integer can be either positive or negative
• Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0)

```            <?php
\$var1 = 6;
\$var2 = 4;
\$answer = \$var1 + \$var2;
print "\$var1 plus \$var2 equals \$answer.";
?>
```

### output

`            6 plus 4 equals 10.          `

## PHP integer Literal

We may specify integers in hexadecimal (base 16) or octal (base 8). The octal number system only uses the digits 0 to 7. hexadecimal uses 0 to 9, then A, B, C, D, E, and F.

To specify number in octal, we must precede it with a 0 (zero).

```            <?php
\$octalnum = 07358;
print \$octalnum;
?>
```

### output

`            7358          `

## Hexadecimal

To specify a number in hexadecimal, precede it with 0x.

```            <?php
\$hexnum = 0x44;
print \$hexnum;
?>
```

### output

`            68            `

## Integer literal

```            <?php
\$a = 1234; # decimal number
print(\$a);
print("\n");
\$a = -123; # a negative number
print(\$a);
print("\n");
\$a = 0123; # octal number (equivalent to 83 decimal)
print(\$a);
print("\n");
\$a = 0x12; # hexadecimal number (equivalent to 18 decimal)
print(\$a);
print("\n");
?>
```

### output

```            1234
-123
83
18
```

## Float

Floats hold fractional numbers as well as very large integer numbers, such as 9.5, 4.00000006, and 123123123123000.

Floating-point numbers are called real numbers or just floats.

## Float Literal

We may also specify an exponent with your float, i.e., 3.14159e4 is equal to 31415.9.

```               <?php
\$a = 1.234;
print (\$a);
print ("\n");
\$a = 1.2e3;
print (\$a);
?>
```

### output

```            1.234
1200            ```

## floating-point arithmetic

```                <?PHP
\$a = 1.132324;
print(\$a);
\$b = \$a + 1.9;
print(\$b);
\$b = \$a + 1.0;
print(\$b);
\$c = 1.1e15;
print(\$c);
\$d = (0.1+0.7) * 10;
print(\$d);
?>
```

### Output

`                1.1323243.0323242.1323241.1E+158            `

## Calculate the area of a circle of given radius

```                <?PHP
\$radius = 2.0;
\$pi = 3.14159;
\$area = \$pi * \$radius * \$radius;

echo("radius = ");
echo(\$radius);
echo("<BR>area = ");
echo(\$area);
?>
```

### Output

`                radius = 2area = 12.56636            `