xref: /PHP-8.4/ext/bcmath/tests/bcfloor.phpt (revision 53593927)
1--TEST--
2bcfloor() function
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7$nums = [
8    '0',
9    '0.00',
10    '-0',
11    '-0.00',
12    '0.01',
13    '0.000000000000000000000000000000000000000001',
14    '-0.01',
15    '-0.000000000000000000000000000000000000000001',
16    '1',
17    '1.0000',
18    '1.0001',
19    '100000.000000000000000000000000000000000000000001',
20    '-1',
21    '-1.0000',
22    '-1.0001',
23    '-100000.000000000000000000000000000000000000000001',
24];
25
26foreach ($nums as $num) {
27    echo str_pad("$num", 50, ' ', STR_PAD_LEFT), ' => ', bcfloor($num), "\n";
28}
29?>
30--EXPECT--
31                                                 0 => 0
32                                              0.00 => 0
33                                                -0 => 0
34                                             -0.00 => 0
35                                              0.01 => 0
36      0.000000000000000000000000000000000000000001 => 0
37                                             -0.01 => -1
38     -0.000000000000000000000000000000000000000001 => -1
39                                                 1 => 1
40                                            1.0000 => 1
41                                            1.0001 => 1
42 100000.000000000000000000000000000000000000000001 => 100000
43                                                -1 => -1
44                                           -1.0000 => -1
45                                           -1.0001 => -2
46-100000.000000000000000000000000000000000000000001 => -100001
47