xref: /PHP-7.0/Zend/tests/dval_to_lval_32.phpt (revision a86fcfbc)
1--TEST--
2zend_dval_to_lval preserves low bits  (32 bit long)
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 4)
6	 die("skip for machines with 32-bit longs");
7?>
8--FILE--
9<?php
10	/* test doubles around -4e21 */
11	$values = [
12		-4000000000000001048576.,
13		-4000000000000000524288.,
14		-4000000000000000000000.,
15		-3999999999999999475712.,
16		-3999999999999998951424.,
17	];
18	/* see if we're rounding negative numbers right */
19	$values[] = -2147483649.8;
20
21	foreach ($values as $v) {
22		var_dump((int)$v);
23	}
24
25?>
26--EXPECT--
27int(-2056257536)
28int(-2055733248)
29int(-2055208960)
30int(-2054684672)
31int(-2054160384)
32int(2147483647)
33