Hi i have come across an issue comparing numbers calculated in the MS Excel and PHP.
The problem i'm having that MS Excel is truncating numbers up to max 15 digits if i understand correctly so i can not compare PHP and MS Excel results: for instance:
so 12.34567890123456789 would be truncated and equal to 12.34567890123450000
,
or
12345.67890123456789012345 would be truncated and equal 12345.67890123450000000
in MS Excel.
How do i achieve the same in PHP so the numbers are truncated to max 15 digits?
I have found a suggestion to use function bcdiv() which allows to truncate numbers to specified number of decimal places, however numbers seem to loose digits in the middle, if more then 10 decimal places are set in the function and it is not the same as in MS EXCEL:
test
echo 123.4567890123456789;
echo bcdiv(123.4567890123456789, 1, 15);
//result
123.4567890123456789
123.4567890123500000000 // have lost digit 4 in the middle of the number
Does anyone know how to truncate numbers in PHP same as in EXCEL?