public static function FromFloat( $value, $detail = true )
	{
		if ( $value instanceof XPath2Item )
		{
			$value = $value->getTypedValue();
		}
		if ( $value instanceof DecimalValue ) return $value;

		if ( ( ! is_numeric( $value ) ) || is_infinite( $value ) || is_nan( $value ) )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FOCA0002", Resources::FOCA0002, array( $value, "Decimal" ) );
		}

		$matched = preg_match( DecimalValue::Pattern, $detail ? sprintf( "%.018g", $value ) : $value, $matches );
		if ( ! $matched )
		{
			throw new \InvalidArgumentException( "The number '$value' cannot be parsed" );
		}

		$sign = isset( $matches['sign'] ) && $matches['sign'] == '-' ? "-" : "";
		$digits = isset( $matches['digits'] ) ? $matches['digits'] : "0";
		$decimals = isset( $matches['decimals'] ) ? "." . $matches['decimals'] : "";
		$exponent = isset( $matches['exponent'] ) ? $matches['exponent'] + 0 : false;
		$factor = str_pad( "1", abs( $exponent ) + 1, "0", STR_PAD_RIGHT );

		$decimal = new DecimalValue( "$sign$digits$decimals" );
		if ( $exponent )
		{
			if ( $exponent > 0 )
			{
				$result = $decimal->Mul( $factor );
			}
			else if ( $exponent && $exponent < 0 )
			{
				$result = $decimal->Div( $factor );
			}
			$decimal = $result;
		}

		return $decimal;
	}
public static function FromFloat( $value, $detail = true )
	{
		if ( $value instanceof XPath2Item )
		{
			$value = $value->getTypedValue();
		}
		if ( $value instanceof DecimalValue ) return $value;

		if ( ( ! is_numeric( $value ) ) || is_infinite( $value ) || is_nan( $value ) )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FOCA0002", Resources::FOCA0002, array( $value, "Decimal" ) );
		}

		$matched = preg_match( DecimalValue::Pattern, $detail ? sprintf( "%.018g", $value ) : $value, $matches );
		if ( ! $matched )
		{
			throw new \InvalidArgumentException( "The number '$value' cannot be parsed" );
		}

		$sign = isset( $matches['sign'] ) && $matches['sign'] == '-' ? "-" : "";
		$digits = isset( $matches['digits'] ) ? $matches['digits'] : "0";
		$decimals = isset( $matches['decimals'] ) ? "." . $matches['decimals'] : "";
		$exponent = isset( $matches['exponent'] ) ? $matches['exponent'] + 0 : false;
		$factor = str_pad( "1", abs( $exponent ) + 1, "0", STR_PAD_RIGHT );

		$decimal = new DecimalValue( "$sign$digits$decimals" );
		if ( $exponent )
		{
			if ( $exponent > 0 )
			{
				$result = $decimal->Mul( $factor );
			}
			else if ( $exponent && $exponent < 0 )
			{
				$result = $decimal->Div( $factor );
			}
			$decimal = $result;
		}

		return $decimal;
	}
public static function FromFloat ( $ value , $ detail = true ) { if ( $ value instanceof XPath2Item ) { $ value = $ value -> getTypedValue ( ) ; } if ( $ value instanceof DecimalValue ) return $ value ; if ( ( ! is_numeric ( $ value ) ) || is_infinite ( $ value ) || is_nan ( $ value ) ) { throw XPath2Exception :: withErrorCodeAndParams ( "FOCA0002" , Resources :: FOCA0002 , array ( $ value , "Decimal" ) ) ; } $ matched = preg_match ( DecimalValue :: Pattern , $ detail ? sprintf ( "%.018g" , $ value ) : $ value , $ matches ) ; if ( ! $ matched ) { throw new \ InvalidArgumentException ( "The number '$value' cannot be parsed" ) ; } $ sign = isset ( $ matches [ 'sign' ] ) && $ matches [ 'sign' ] == '-' ? "-" : "" ; $ digits = isset ( $ matches [ 'digits' ] ) ? $ matches [ 'digits' ] : "0" ; $ decimals = isset ( $ matches [ 'decimals' ] ) ? "." . $ matches [ 'decimals' ] : "" ; $ exponent = isset ( $ matches [ 'exponent' ] ) ? $ matches [ 'exponent' ] + 0 : false ; $ factor = str_pad ( "1" , abs ( $ exponent ) + 1 , "0" , STR_PAD_RIGHT ) ; $ decimal = new DecimalValue ( "$sign$digits$decimals" ) ; if ( $ exponent ) { if ( $ exponent > 0 ) { $ result = $ decimal -> Mul ( $ factor ) ; } else if ( $ exponent && $ exponent < 0 ) { $ result = $ decimal -> Div ( $ factor ) ; } $ decimal = $ result ; } return $ decimal ; }
Creates an instance from a Float value
@param float $value
@param bool $detail (optional: default = true) Expand the number to the most digits
Creates an instance from a Float value