mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-23 13:14:45 +00:00
30c880b5e6
* Bitwise Functions and 32-bit When running the test suite with 32-bit PHP, a failure was reported in BITLSHIFT. In fact, all of the following are vulnerable to problems, and didn't report any failures only because of a scarcity of tests: - BITAND - BITOR - BITXOR - BITRSHIFT - BITLSHIFT Those last 2 can be resolved fairly easily by using multiplication by a power of 2 rather than shifting. The first 3 are a tougher nut to crack, and I will continue to think how they might best be approached. For now, I have added skippable tests for each of them, which at least documents the problem. Aside from adding many new tests, some bugs were correctd: - The function list in Calculation.php pointed BITXOR to BITOR. - All 5 functions allow null/false/true parameters. - BIT*SHIFT shift amount must be numeric, can be negative, allows decimal portion (which is truncated to integer), and has an absolute value limit of 53. - Because BITRSHIFT allows negative shift amount, its result can overflow (in which case return NAN). - All 5 functions disallow negative parameters (except ...SHIFT second parameter). This was coded, but the code had been thwarted by an earlier is_int test. * Full Support for AND/OR/XOR on 32-bit Previous version did not support operands 2**32 through 2**48.
35 lines
968 B
PHP
35 lines
968 B
PHP
<?php
|
|
|
|
return [
|
|
[55, '21, 39'],
|
|
[248, '200, "184"'],
|
|
[248, '72, 184'],
|
|
['#NUM!', '12.34, 56.78'], // non-integer argument
|
|
[60, '12.00, 56.00'],
|
|
['#VALUE!', '"ABC", "DEF"'],
|
|
['#VALUE!', '"ABC", 1'],
|
|
['#VALUE!', '1, "DEF"'],
|
|
['#NUM!', '12.00, 2.82E14'],
|
|
[5123456789, '5123456788, 1'],
|
|
[7415004949, '5123456789, 7123456789'],
|
|
['#NUM!', '-5123456788, 1'],
|
|
['#NUM!', 'power(2, 50), 1'], // argument >= 2**48
|
|
['#NUM!', '1, power(2, 50)'], // argument >= 2**48
|
|
['#NUM!', '-2, 1'], // negative argument
|
|
['#NUM!', '2, -1'], // negative argument
|
|
['#NUM!', '-2, -1'], // negative argument
|
|
['#NUM!', '3.1, 1'], // non-integer argument
|
|
['#NUM!', '3, 1.1'], // non-integer argument
|
|
[4, '4, Q15'],
|
|
[4, '4, null'],
|
|
[4, '4, false'],
|
|
[5, '4, true'],
|
|
['exception', ''],
|
|
['exception', '2'],
|
|
[4, ', 4'],
|
|
[4, 'Q15, 4'],
|
|
[4, 'false, 4'],
|
|
[5, 'true, 4'],
|
|
[9, 'A2, 1'],
|
|
];
|