mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-24 22:08:19 +00:00
d99a4a3fac
* Improve Coverage of BIN2DEC etc. The following functions have some special handling depending on the Calculation mode: - BIN2DEC - BIN2HEX - BIN2OCT - DEC2BIN - DEC2HEX - DEC2OCT - HEX2BIN - HEX2DEC - HEX2OCT - OCT2BIN - OCT2DEC - OCT2HEX Ods accepts boolean for its numeric argument. This had already been coded, but there were no tests for it. Gnumeric allows the use of non-integer argument where Excel/Ods do not. The existing code allowed this for certain functions but not for others. Gnumeric consistently allows it, so there is no need for parameter gnumericCheck in convertBase::ValidateValue. Again, there were no tests for this. There were some minor changes needed: - In functions where you are allowed to specify the numnber of "places" in the result, there is an upper bound of 10 which had not been enforced. - Negative values were not handled correctly in some cases. - There was at least one (avoidable) error on a 32-bit system. - Some upper and lower bounds were not being enforced. In addition to enforcing those, the bounds are now defined as class constants in ConvertDecimal. Many tests have been added, so that Engineering is now almost 100% covered. The exception is some BESSEL code. There have been some recent changes to BESSEL which are not yet part of my fork, so I could not address those now. However, I freely admit that, when I looked at the uncovered portion, it seemed like it might be a difficult task, so I probably wouldn't have tackled it anyhow. In particular, the uncovered code seemed to deal with very large numbers, and, although PhpSpreadsheet and Excel both give very large results for these conditions, their answers are not particularly close to each other. I think we're dealing with resuts approaching infinity. More study is needed.
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
return [
|
|
['B2', '10110010'],
|
|
['#NUM!', '111001010101'], // Too large
|
|
['00FB', '11111011, 4'], // Leading places
|
|
['0FB', '11111011, 3.75'], // Leading places as a float
|
|
['#NUM!', '11111011, -1'], // Leading places negative
|
|
['#VALUE!', '11111011, "ABC"'], // Leading places non-numeric
|
|
['E', '"1110"'],
|
|
['5', '101'],
|
|
['2', '10'],
|
|
['0', '0'],
|
|
['#NUM!', '21'], // Invalid binary number
|
|
['#VALUE!', 'true'], // ODS accepts Boolean, Excel/Gnumeric don't
|
|
['#VALUE!', 'false'], // ODS accepts Boolean, Excel/Gnumeric don't
|
|
['FFFFFFFF95', '1110010101'], // 2's Complement
|
|
['FFFFFFFFFF', '1111111111'], // 2's Complement
|
|
['FFFFFFFE00', '1000000000'], // lowest negative
|
|
['1FF', '111111111'], // highest positive
|
|
['0', '0000000000'],
|
|
['1', '000000001'],
|
|
['100', '0100000000'],
|
|
['100', '100000000'],
|
|
['FFFFFFFF00', '1100000000'],
|
|
['0003', '11, 4'],
|
|
['#NUM!', '11, 0'],
|
|
['#NUM!', '11, -1'],
|
|
['#NUM!', '11, 14'],
|
|
['#NUM!', '10001, 1'],
|
|
['11', '10001, 2'],
|
|
[5, 'A2'],
|
|
['#NUM!', '"A2"'],
|
|
[0, 'A3'],
|
|
['exception', ''],
|
|
];
|