XBRL-Instance.php
public static function inferPrecision( $value, $decimals )
	{
		if ( $decimals == "INF" ) return INF;
		if ( ! is_numeric( $value ) ) return false;

		$fValue = floatval( $value );

		if ( $value === false ) return false;
		if ( $decimals === "" ) return 0;

		$precision = 0;
		if ( preg_match( '/[-+]?[0]*([1-9]?[0-9]*)([.])?(0*)([1-9]?[0-9]*)?([eE])?([-+]?[0-9]*)?/', $value, $matches ) )
		{
			list( $all, $nonZeroInt, $period, $zeroDec, $nonZeroDec, $e, $exp ) = $matches;
			$precision = (
				$nonZeroInt
					? strlen( $nonZeroInt )
					: ( $nonZeroDec ? -strlen( $zeroDec ) : 0 )
				) + ( $exp ? intval( $exp ) : 0 ) + ( intval( $decimals ) );

			if ( $precision < 0 ) $precision = 0;
		}

		return $precision;
	}
public static function inferPrecision( $value, $decimals )
	{
		if ( $decimals == "INF" ) return INF;
		if ( ! is_numeric( $value ) ) return false;

		$fValue = floatval( $value );

		if ( $value === false ) return false;
		if ( $decimals === "" ) return 0;

		$precision = 0;
		if ( preg_match( '/[-+]?[0]*([1-9]?[0-9]*)([.])?(0*)([1-9]?[0-9]*)?([eE])?([-+]?[0-9]*)?/', $value, $matches ) )
		{
			list( $all, $nonZeroInt, $period, $zeroDec, $nonZeroDec, $e, $exp ) = $matches;
			$precision = (
				$nonZeroInt
					? strlen( $nonZeroInt )
					: ( $nonZeroDec ? -strlen( $zeroDec ) : 0 )
				) + ( $exp ? intval( $exp ) : 0 ) + ( intval( $decimals ) );

			if ( $precision < 0 ) $precision = 0;
		}

		return $precision;
	}
public static function inferPrecision ( $ value , $ decimals ) { if ( $ decimals == "INF" ) return INF ; if ( ! is_numeric ( $ value ) ) return false ; $ fValue = floatval ( $ value ) ; if ( $ value === false ) return false ; if ( $ decimals === "" ) return 0 ; $ precision = 0 ; if ( preg_match ( '/[-+]?[0]*([1-9]?[0-9]*)([.])?(0*)([1-9]?[0-9]*)?([eE])?([-+]?[0-9]*)?/' , $ value , $ matches ) ) { list ( $ all , $ nonZeroInt , $ period , $ zeroDec , $ nonZeroDec , $ e , $ exp ) = $ matches ; $ precision = ( $ nonZeroInt ? strlen ( $ nonZeroInt ) : ( $ nonZeroDec ? - strlen ( $ zeroDec ) : 0 ) ) + ( $ exp ? intval ( $ exp ) : 0 ) + ( intval ( $ decimals ) ) ; if ( $ precision < 0 ) $ precision = 0 ; } return $ precision ; }
Infer the precision given a value and a decimals value

@param string|number $value
@param string|number $decimals
@return string|boolean|number
Infer the precision given a value and a decimals value