-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07_numbers.php
101 lines (76 loc) · 1.36 KB
/
07_numbers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/*
* There are three main numeric types in PHP:
* Integer
* Float
* Number Strings
*
* In addition, PHP has two more data types used for numbers:
* Infinity
* NaN
* */
$total_flats = 2;
$per_flat_price = 5000.00;
$total_price = "1e4";
$final = 2 * $total_price; // returns float
var_dump($total_flats, $per_flat_price, $total_price, $final);
echo '<pre>';
echo '===== Check integer ====';
echo '<pre>';
/*
* Check integer
* is_int()
* is_integer() - alias of is_int()
* is_long() - alias of is_int()
* */
$x = 5985;
var_dump(is_int($x));
$y = 59.85;
var_dump(is_int($y));
echo '<pre>';
echo '===== Check Float ====';
echo '<pre>';
/*
* Check Float
* is_float()
* is_double() - alias of is_float()
* */
$x = 10.365;
var_dump(is_float($x));
echo '<pre>';
echo '===== Check Numeric ====';
echo '<pre>';
/*
* Check Numeric
* is_numeric()
* */
$x = 5985;
var_dump(is_numeric($x));
$x = "5985";
var_dump(is_numeric($x));
$x = "59.85" + 100;
var_dump(is_numeric($x));
$x = "Hello";
var_dump(is_numeric($x));
echo '<pre>';
echo '===== Check Infinity ====';
echo '<pre>';
/*
* Check Infinity
* is_finite()
* is_infinite()
* */
$x = 1.9e411;
var_dump($x);
var_dump(is_finite($x));
var_dump(is_infinite($x));
echo '<pre>';
echo '===== Check NaN ====';
echo '<pre>';
/*
* Check NaN
* is_nan()
* */
$x = acos(8);
var_dump($x);
var_dump(is_nan($x));