SwatI18N/SwatI18NLocale.php
protected function getFractionalPrecision($value)
    {
        /*
         * This is a bit hacky (and probably slow). We get the string
         * representation and then count the number of digits after the decimal
         * separator. This may or may not be faster than the equivalent
         * IEEE-754 decomposition (written in PHP). The string-based code has
         * not been profiled against the equivalent IEEE-754 code.
         */

        $value = (float) $value;

        // get current locale
        $locale = self::get();

        $precision = 0;
        $lc = $locale->getLocaleInfo();
        $str_value = (string) $value;

        $e_pos = mb_stripos($str_value, 'E-');
        if ($e_pos !== false) {
            $precision += (int) mb_substr($str_value, $e_pos + 2);
            $str_value = mb_substr($str_value, 0, $e_pos);
        }

        $decimal_pos = mb_strpos($str_value, $lc['decimal_point']);
        if ($decimal_pos !== false) {
            $precision +=
                mb_strlen($str_value) -
                $decimal_pos -
                mb_strlen($lc['decimal_point']);
        }

        return $precision;
    }
protected function getFractionalPrecision($value)
    {
        /*
         * This is a bit hacky (and probably slow). We get the string
         * representation and then count the number of digits after the decimal
         * separator. This may or may not be faster than the equivalent
         * IEEE-754 decomposition (written in PHP). The string-based code has
         * not been profiled against the equivalent IEEE-754 code.
         */

        $value = (float) $value;

        // get current locale
        $locale = self::get();

        $precision = 0;
        $lc = $locale->getLocaleInfo();
        $str_value = (string) $value;

        $e_pos = mb_stripos($str_value, 'E-');
        if ($e_pos !== false) {
            $precision += (int) mb_substr($str_value, $e_pos + 2);
            $str_value = mb_substr($str_value, 0, $e_pos);
        }

        $decimal_pos = mb_strpos($str_value, $lc['decimal_point']);
        if ($decimal_pos !== false) {
            $precision +=
                mb_strlen($str_value) -
                $decimal_pos -
                mb_strlen($lc['decimal_point']);
        }

        return $precision;
    }
protected function getFractionalPrecision ( $ value ) { /*
         * This is a bit hacky (and probably slow). We get the string
         * representation and then count the number of digits after the decimal
         * separator. This may or may not be faster than the equivalent
         * IEEE-754 decomposition (written in PHP). The string-based code has
         * not been profiled against the equivalent IEEE-754 code.
         */ $ value = ( float ) $ value ; // get current locale $ locale = self :: get ( ) ; $ precision = 0 ; $ lc = $ locale -> getLocaleInfo ( ) ; $ str_value = ( string ) $ value ; $ e_pos = mb_stripos ( $ str_value , 'E-' ) ; if ( $ e_pos !== false ) { $ precision += ( int ) mb_substr ( $ str_value , $ e_pos + 2 ) ; $ str_value = mb_substr ( $ str_value , 0 , $ e_pos ) ; } $ decimal_pos = mb_strpos ( $ str_value , $ lc [ 'decimal_point' ] ) ; if ( $ decimal_pos !== false ) { $ precision += mb_strlen ( $ str_value ) - $ decimal_pos - mb_strlen ( $ lc [ 'decimal_point' ] ) ; } return $ precision ; }
Gets the fractional precision of a floating point number

This gets the number of digits after the decimal point.

@param float $value the value for which to get the fractional precision.

@return integer the fractional precision of the value.
Gets the fractional precision of a floating point number