/** * Adds leading zeros if necessary to the unscaled value to represent the full decimal number. * * @return string */ private function getUnscaledValueWithLeadingZeros() { $value = (string) $this->intVal; $targetLength = $this->scale + 1; $negative = $this->intVal->isNegative(); $length = strlen($value); if ($negative) { --$length; } if ($length >= $targetLength) { return $value; } if ($negative) { $value = substr($value, 1); } $value = str_pad($value, $targetLength, '0', STR_PAD_LEFT); if ($negative) { $value = '-' . $value; } return $value; }