protected function formatDecimal($string)
{
$dp = strpos($string, '.');
$decimal = '';
$decimalDigits = $this->formatInfo->DecimalDigits;
$decimalSeparator = $this->formatInfo->DecimalSeparator;
//do the correct rounding here
//$string = round(floatval($string), $decimalDigits);
if (is_int($dp)) {
if ($decimalDigits == -1) {
$decimal = substr($string, $dp + 1);
} else {
if (is_int($decimalDigits)) {
$float = round((double) $string, $decimalDigits);
if (strpos((string) $float, '.') === false) {
$decimal = str_pad($decimal, $decimalDigits, '0');
} else {
$decimal = substr($float, strpos($float, '.') + 1);
if (strlen($decimal) < $decimalDigits) {
$decimal = str_pad($decimal, $decimalDigits, '0');
}
}
} else {
return $decimal;
}
}
return $decimalSeparator . $decimal;
} else {
if ($decimalDigits > 0) {
return $decimalSeparator . str_pad($decimal, $decimalDigits, '0');
}
}
return $decimal;
}