@@ -459,15 +459,19 @@ protected function addToPreferredOthers(string $leftSpace)
459
459
$ totalNeeded = Math::add ($ autoNeededTotal , $ pixelNeededTotal );
460
460
$ totalToAdd = Math::min ($ leftSpace , $ totalNeeded );
461
461
// we know how much we can distribute
462
+ Math::setAccurate (true );
462
463
$ autoTotalRatio = Math::div ($ autoNeededTotal , $ totalNeeded );
463
464
$ addToAutoTotal = Math::mul ($ autoTotalRatio , $ totalToAdd );
465
+ Math::setAccurate (false );
464
466
$ addToPixelTotal = Math::sub ($ totalToAdd , $ addToAutoTotal );
465
467
// we know how much space we can add to each column type (auto and pixel)
466
468
// now we must distribute this space according to concrete column needs
467
469
foreach ($ this ->autoColumns as $ columnIndex => $ columns ) {
468
470
if (isset ($ autoNeeded [$ columnIndex ])) {
471
+ Math::setAccurate (true );
469
472
$ neededRatio = Math::div ($ autoNeeded [$ columnIndex ], $ autoNeededTotal );
470
473
$ add = Math::mul ($ neededRatio , $ addToAutoTotal );
474
+ Math::setAccurate (false );
471
475
$ columnWidth = Math::add ($ columns [0 ]->getDimensions ()->getWidth (), $ add );
472
476
foreach ($ columns as $ column ) {
473
477
$ colDmns = $ column ->getDimensions ();
@@ -478,8 +482,10 @@ protected function addToPreferredOthers(string $leftSpace)
478
482
}
479
483
foreach ($ this ->pixelColumns as $ columnIndex => $ columns ) {
480
484
if (isset ($ pixelNeeded [$ columnIndex ])) {
485
+ Math::setAccurate (true );
481
486
$ neededRatio = Math::div ($ pixelNeeded [$ columnIndex ], $ pixelNeededTotal );
482
487
$ add = Math::mul ($ neededRatio , $ addToPixelTotal );
488
+ Math::setAccurate (false );
483
489
$ columnWidth = Math::add ($ columns [0 ]->getDimensions ()->getWidth (), $ add );
484
490
foreach ($ columns as $ column ) {
485
491
$ colDmns = $ column ->getDimensions ();
@@ -500,7 +506,6 @@ protected function addToPreferredOthers(string $leftSpace)
500
506
protected function getCurrentOthersWidth ()
501
507
{
502
508
$ currentOthersWidth = '0 ' ;
503
-
504
509
foreach ($ this ->autoColumns as $ columns ) {
505
510
$ currentOthersWidth = Math::add ($ currentOthersWidth , $ columns [0 ]->getDimensions ()->getInnerWidth ());
506
511
}
@@ -555,7 +560,9 @@ protected function expandPercentsToMin(string $availableSpace)
555
560
$ maxPercentRatioIndex = 0 ;
556
561
$ ratioPercent = '0 ' ;
557
562
foreach ($ this ->percentages as $ columnIndex => $ percent ) {
563
+ Math::setAccurate (true );
558
564
$ ratio = Math::div ($ this ->minWidths [$ columnIndex ], $ percent );
565
+ Math::setAccurate (false );
559
566
if (Math::comp ($ ratio , $ maxPercentRatio ) > 0 ) {
560
567
$ maxPercentRatio = $ ratio ;
561
568
$ maxPercentRatioIndex = $ columnIndex ;
@@ -975,8 +982,10 @@ protected function shrinkToFit(string $availableSpace, int $step)
975
982
// minimal stays minimal, decreasing pixels
976
983
$ toPixelDisposition = Math::sub ($ nonPercentageSpace , $ autoColumnsMinWidth );
977
984
foreach ($ this ->pixelColumns as $ columnIndex => $ columns ) {
985
+ Math::setAccurate (true );
978
986
$ ratio = Math::div ($ this ->preferredWidths [$ columnIndex ], $ totalPixelWidth );
979
987
$ columnWidth = Math::mul ($ toPixelDisposition , $ ratio );
988
+ Math::setAccurate (false );
980
989
foreach ($ columns as $ column ) {
981
990
$ columnDimensions = $ column ->getDimensions ();
982
991
$ columnDimensions ->setWidth (Math::add ($ columnWidth , $ column ->getStyle ()->getHorizontalPaddingsWidth ()));
@@ -998,8 +1007,10 @@ protected function shrinkToFit(string $availableSpace, int $step)
998
1007
$ toAutoDisposition = Math::sub ($ nonPercentageSpace , $ totalPixelWidth );
999
1008
$ nonMinWidthColumns = [];
1000
1009
foreach ($ this ->autoColumns as $ columnIndex => $ columns ) {
1010
+ Math::setAccurate (true );
1001
1011
$ ratio = Math::div ($ this ->contentWidths [$ columnIndex ], $ autoColumnsMaxWidth );
1002
1012
$ columnWidth = Math::mul ($ toAutoDisposition , $ ratio );
1013
+ Math::setAccurate (false );
1003
1014
if (Math::comp ($ this ->minWidths [$ columnIndex ], $ columnWidth ) > 0 ) {
1004
1015
$ toAutoDisposition = Math::sub ($ toAutoDisposition , Math::sub ($ this ->minWidths [$ columnIndex ], $ columnWidth ));
1005
1016
$ columnWidth = $ this ->minWidths [$ columnIndex ];
@@ -1013,8 +1024,10 @@ protected function shrinkToFit(string $availableSpace, int $step)
1013
1024
}
1014
1025
}
1015
1026
foreach ($ nonMinWidthColumns as $ columnIndex => $ columns ) {
1027
+ Math::setAccurate (true );
1016
1028
$ ratio = Math::div ($ this ->contentWidths [$ columnIndex ], $ autoColumnsMaxWidth );
1017
1029
$ columnWidth = Math::mul ($ toAutoDisposition , $ ratio );
1030
+ Math::setAccurate (false );
1018
1031
foreach ($ columns as $ column ) {
1019
1032
$ columnDimensions = $ column ->getDimensions ();
1020
1033
$ columnDimensions ->setWidth (Math::add ($ columnWidth , $ column ->getStyle ()->getHorizontalPaddingsWidth ()));
@@ -1061,8 +1074,10 @@ protected function addToOthers(string $leftSpace, bool $withPreferred = false)
1061
1074
if (!empty ($ this ->autoColumns )) {
1062
1075
$ autoColumnsMaxWidth = $ this ->getAutoColumnsMaxWidth ();
1063
1076
foreach ($ this ->autoColumns as $ columnIndex => $ columns ) {
1077
+ Math::setAccurate (true );
1064
1078
$ ratio = Math::div ($ this ->contentWidths [$ columnIndex ], $ autoColumnsMaxWidth );
1065
1079
$ add = Math::mul ($ leftSpace , $ ratio );
1080
+ Math::setAccurate (false );
1066
1081
$ colWidth = Math::add ($ columns [0 ]->getDimensions ()->getWidth (), $ add );
1067
1082
foreach ($ columns as $ column ) {
1068
1083
$ colDmns = $ column ->getDimensions ();
@@ -1130,8 +1145,10 @@ protected function tryPreferred(string $leftSpace, bool $outerWidthSet)
1130
1145
$ addToPercents = Math::min ($ neededTotal , $ forPercentages );
1131
1146
foreach ($ this ->percentColumns as $ columnIndex => $ columns ) {
1132
1147
if (Math::comp ($ addToPercents , $ neededTotal ) < 0 ) {
1148
+ Math::setAccurate (true );
1133
1149
$ ratio = Math::div ($ this ->percentages [$ columnIndex ], $ totalPercentages );
1134
1150
$ add = Math::mul ($ ratio , $ addToPercents );
1151
+ Math::setAccurate (false );
1135
1152
} else {
1136
1153
if (isset ($ needed [$ columnIndex ])) {
1137
1154
$ add = $ needed [$ columnIndex ];
0 commit comments