@@ -12,10 +12,12 @@ define("MAX_32Bit", 2147483647);
12
12
define ("MIN_64Bit " , -9223372036854775807 - 1 );
13
13
define ("MIN_32Bit " , -2147483647 - 1 );
14
14
15
- $ longVals = array (
15
+ $ numbers = array (
16
16
MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
17
17
MAX_32Bit + 1 , MIN_32Bit - 1 , MAX_32Bit * 2 , (MAX_32Bit * 2 ) + 1 , (MAX_32Bit * 2 ) - 1 ,
18
- MAX_64Bit -1 , MAX_64Bit + 1 , MIN_64Bit + 1 , MIN_64Bit - 1
18
+ MAX_64Bit - 1 , MAX_64Bit + 1 , MIN_64Bit + 1 , MIN_64Bit - 1 ,
19
+ // floats rounded as int
20
+ MAX_64Bit - 1024.0 , MIN_64Bit + 1024.0
19
21
);
20
22
21
23
$ precisions = array (
@@ -31,12 +33,12 @@ $precisions = array(
31
33
PHP_INT_MIN ,
32
34
);
33
35
34
- foreach ($ longVals as $ longVal ) {
36
+ foreach ($ numbers as $ number ) {
35
37
echo "--- testing: " ;
36
- var_dump ($ longVal );
38
+ var_dump ($ number );
37
39
foreach ($ precisions as $ precision ) {
38
40
echo "... with precision " . $ precision . ": " ;
39
- var_dump (number_format ($ longVal , $ precision ));
41
+ var_dump (number_format ($ number , $ precision ));
40
42
}
41
43
}
42
44
@@ -199,8 +201,30 @@ foreach ($longVals as $longVal) {
199
201
--- testing: float(-9.223372036854776E+18)
200
202
... with precision 5: string(32) "-9,223,372,036,854,775,808.00000"
201
203
... with precision 0: string(26) "-9,223,372,036,854,775,808"
202
- ... with precision -1: string(26) "-9,223,372,036,854,775,808"
203
- ... with precision -5: string(26) "-9,223,372,036,854,800,384"
204
+ ... with precision -1: string(26) "-9,223,372,036,854,775,810"
205
+ ... with precision -5: string(26) "-9,223,372,036,854,800,000"
206
+ ... with precision -10: string(26) "-9,223,372,040,000,000,000"
207
+ ... with precision -11: string(26) "-9,223,372,000,000,000,000"
208
+ ... with precision -17: string(26) "-9,200,000,000,000,000,000"
209
+ ... with precision -19: string(27) "-10,000,000,000,000,000,000"
210
+ ... with precision -20: string(1) "0"
211
+ ... with precision -9223372036854775808: string(1) "0"
212
+ --- testing: float(9.223372036854775E+18)
213
+ ... with precision 5: string(31) "9,223,372,036,854,774,784.00000"
214
+ ... with precision 0: string(25) "9,223,372,036,854,774,784"
215
+ ... with precision -1: string(25) "9,223,372,036,854,774,780"
216
+ ... with precision -5: string(25) "9,223,372,036,854,800,000"
217
+ ... with precision -10: string(25) "9,223,372,040,000,000,000"
218
+ ... with precision -11: string(25) "9,223,372,000,000,000,000"
219
+ ... with precision -17: string(25) "9,200,000,000,000,000,000"
220
+ ... with precision -19: string(26) "10,000,000,000,000,000,000"
221
+ ... with precision -20: string(1) "0"
222
+ ... with precision -9223372036854775808: string(1) "0"
223
+ --- testing: float(-9.223372036854775E+18)
224
+ ... with precision 5: string(32) "-9,223,372,036,854,774,784.00000"
225
+ ... with precision 0: string(26) "-9,223,372,036,854,774,784"
226
+ ... with precision -1: string(26) "-9,223,372,036,854,774,780"
227
+ ... with precision -5: string(26) "-9,223,372,036,854,800,000"
204
228
... with precision -10: string(26) "-9,223,372,040,000,000,000"
205
229
... with precision -11: string(26) "-9,223,372,000,000,000,000"
206
230
... with precision -17: string(26) "-9,200,000,000,000,000,000"
0 commit comments