public function formatNumber(
        $value,
        $decimals = null,
        array $format = array()
    ) {
        $value = (float) $value;

        $format = $this->getNumberFormat()->override($format);

        if ($decimals === null) {
            $decimals = $this->getFractionalPrecision($value);
        }

        $value = round($value, $decimals);

        $integer_part = $this->formatIntegerGroupings($value, $format);
        $fractional_part = $this->formatFractionalPart(
            $value,
            $decimals,
            $format
        );

        $sign = $value < 0 ? '-' : '';

        $formatted_value = $sign . $integer_part . $fractional_part;

        return $formatted_value;
    }