IDiv
@param ValueProxy $val
@return Integer
493624
protected function IDiv( $val )
	{
		$val = $this->getOtherValue( $val );

		if ( is_infinite( $this->_value ) && $val == 0 || $val == 0 )
		{
			throw XPath2Exception::withErrorCode( "FOAR0001", Resources::FOAR0001 );
		}

		if ( is_infinite( $this->_value ) || is_nan( $this->_value ) || is_nan( $val ) )
		{
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );
		}

	    return Integer::FromValue( round( $this->_value / $val ) );
	}
1105059
public double setValue(int idx, double val) {
        int vSize = MVecArray.count(varBeliefs);
        if (idx < vSize) {
            return MVecArray.setValue(idx, val, varBeliefs);
        } else {
            return MVecArray.setValue(idx - vSize, val, facBeliefs);
        }
    }
963071
public static function OperatorDivide( $val1, $val2 )
	{
		switch ( ValueProxy::$conv_t[ $val1->GetValueCode() ][ $val2->GetValueCode()] )
		{
			case -1:
				return  $val2->Promote( $val1)->Div( $val2 );

			case 0:
				return  $val1->Div( $val2 );

			case 1:
				return  $val1->Div( $val1->Promote( $val2 ) );

			default:
				{
					if ( ValueProxy::$conv_t[ $val2->GetValueCode() ][ $val1->GetValueCode() ] == 1)
						return  $val2->Promote( $val1 )->Div( $val2 );
					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
						array(
							"op:div",
							SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject(  $val1 ), XmlTypeCardinality::One ),
							SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject(  $val2 ), XmlTypeCardinality::One )
						)
					);
				}
		}
	}
809554
protected function Mul( $val )
	{
		if  (! $val->getIsNumeric() ) return $this;

		$value1 = ValueProxy::Unwrap( $this );
		if ( $value1 instanceof Integer ) $value1 = $value1->getValue();
		$value2 = ValueProxy::Unwrap( $val );
		if ( $value2 instanceof Integer ) $value2 = $value2->getValue();
		return new IntegerProxy( Integer::FromValue( $value1 * $value2 ) );
	}
93918
public double setValue(int idx, double val) {
        double prev = values[idx];
        values[idx] = val;
        return prev;
    }
524610
protected function Div( $val )
	{
		$val = $this->getOtherValue( $val );
		if ( $val == 0 )
		{
			return new FloatProxy( $this->_value >= 0 ? INF : -INF );
		}

	    return new FloatProxy( $this->_value / $val );
	}
380400
protected function Promote( $val )
	{
		$val = ValueProxy::Unwrap( $val );
		if ( $val instanceof IXmlSchemaType )
		{
			$val = $val->getValue();
		}

		$result = Convert::ToInt64( $val );
		return new LongProxy( Convert::ToInt64( $val) );
	}
308796
protected function Sub( $val )
	{
		if ( ! $val instanceof ByteProxy ) throw new \InvalidArgumentException();
		return new IntProxy( $this->_value - $val->_value );
	}
243895
public static function getSumOfDigits($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $nbs = str_split(pow(abs($val), 1));
        $result = 0;
        foreach ($nbs as $nb) {
            $result += (int) $nb;
        }
        return $result;
    }
152778
function intval($index = '', $default = 0) {
		$value = $default;
		if (isset($_POST[$index])) {
			$value = $_POST[$index];
		} else if (isset($_GET[$index])) {
			$value = $_GET[$index];
		}
		return intval($value);
	}
1004922
protected function IDiv( $val )
	{
		$numerator = $this->_value;
		$denominator = $val->getValue();

		if ( $denominator == 0 )
			throw XPath2Exception::withErrorCode( "FOAR0001", Resources::FOAR0001 );

		if ( is_nan( $denominator ) )
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );

		if ( is_nan( $numerator ) || is_infinite( $numerator ) )
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );

		return Integer::FromValue( Convert::ToDecimal( $numerator / $denominator )->getIntegerPart() );
	}
31505
public function getUserValue($val)
    {
        $formatter = $this->getFormatter();

        $formattedValue = $formatter->format($val, $this->getFormatType());

        return (string) $this->getPrefix().$formattedValue.$this->getSuffix();
    }
280763
public static function EqualsValue( $val1, $val2 )
	{
		switch ( ValueProxy::$conv_t[ $val1->GetValueCode() ][ $val2->GetValueCode() ] )
		{
			case -1:
				return $val2->Promote( $val1 )->Eq( $val2 );

			case 0:
				return $val1->Eq( $val2 );

			case 1:
				return $val1->Eq( $val1->Promote( $val2 ) );

			default:

				if ( ValueProxy::$conv_t[ $val2->GetValueCode() ][ $val1->GetValueCode() ] == 1 )
				{
					return $val2->Promote( $val1 )->Eq( $val2 );
				}

				throw XPath2Exception::withErrorCodeAndParams( "", Resources::BinaryOperatorNotDefined,
					array(
						"op:eq",
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val1 ), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val2 ), XmlTypeCardinality::One )
					)
				);
		}
	}
1345209
protected function Add( $val )
	{
		if  (! $val->getIsNumeric() ) return $this;
		$value2 = $val->ToInt( null );
		$integer = ValueProxy::Unwrap( $this );
	    return new IntegerProxy( $integer->getValue() + $value2 );
	}
936893
protected function Mod( $val )
	{
		if  (! $val->getIsNumeric() ) return $this;
		$mod = Integer::FromValue( $this->ToDecimal( null )->Mod( $val->ToDecimal( null ) )->getIntegerPart() );
		return $mod;
		// return new IntegerProxy( $this->ToDouble( null ) % $value2 );
	}
93878
private static function contextValueToString($val)
    {

        if (is_bool($val)) {
            return var_export($val, true);

        } elseif (is_scalar($val)) {
            return (string)$val;

        } elseif (is_null($val)) {
            return 'NULL';

        } elseif (is_object($val)) {
            if (is_callable(array($val, '__toString'))) {
                return (string)$val;
            }
            return get_class($val);
        }
        return gettype($val);
    }
291697
protected function booleanValue($val)
    {
        if (is_numeric($val)) {
            return (bool) $val;
        } else {
            return (in_array(strtolower($val), array('true', 't', 'y', 'yes'), true) ? true : false);
        }
    }