Complex number mask for integers containing a single dot (#1227)
This commit is contained in:
parent
1b4098da8e
commit
617ea476c0
|
@ -601,6 +601,7 @@ class NumberFormat extends Supervisor
|
||||||
{
|
{
|
||||||
$sign = ($number < 0.0);
|
$sign = ($number < 0.0);
|
||||||
$number = abs($number);
|
$number = abs($number);
|
||||||
|
|
||||||
if ($splitOnPoint && strpos($mask, '.') !== false && strpos($number, '.') !== false) {
|
if ($splitOnPoint && strpos($mask, '.') !== false && strpos($number, '.') !== false) {
|
||||||
$numbers = explode('.', $number);
|
$numbers = explode('.', $number);
|
||||||
$masks = explode('.', $mask);
|
$masks = explode('.', $mask);
|
||||||
|
@ -639,6 +640,9 @@ class NumberFormat extends Supervisor
|
||||||
// Scientific format
|
// Scientific format
|
||||||
$value = sprintf('%5.2E', $value);
|
$value = sprintf('%5.2E', $value);
|
||||||
} elseif (preg_match('/0([^\d\.]+)0/', $format) || substr_count($format, '.') > 1) {
|
} elseif (preg_match('/0([^\d\.]+)0/', $format) || substr_count($format, '.') > 1) {
|
||||||
|
if ($value == (int) $value && substr_count($format, '.') === 1) {
|
||||||
|
$value *= 10 ** strlen(explode('.', $format)[1]);
|
||||||
|
}
|
||||||
$value = self::complexNumberFormatMask($value, $format);
|
$value = self::complexNumberFormatMask($value, $format);
|
||||||
} else {
|
} else {
|
||||||
$sprintf_pattern = "%0$minWidth." . strlen($right) . 'f';
|
$sprintf_pattern = "%0$minWidth." . strlen($right) . 'f';
|
||||||
|
|
|
@ -58,6 +58,16 @@ return [
|
||||||
5.5555000000000003,
|
5.5555000000000003,
|
||||||
'0.00#',
|
'0.00#',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'12 345.67',
|
||||||
|
12345.67,
|
||||||
|
'#\ ##0.00',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'1234 567.00',
|
||||||
|
1234567.00,
|
||||||
|
'#\ ##0.00',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'5.556',
|
'5.556',
|
||||||
5.5555000000000003,
|
5.5555000000000003,
|
||||||
|
|
Loading…
Reference in New Issue