IDiv
@param ValueProxy $val
@return Integer
196194
protected function IDiv( $val )
	{
		if ( ! $val instanceof IntProxy ) throw new \InvalidArgumentException();

		/**
		 * @var DecimalValue $result
		 */
		$result = $this->Div( $val );
		return Integer::FromValue( $result->getValue()->getIntegerPart() );
	}
119234
protected function realToBinary($val)
    {
        $bdata = self::typeBytes("2", 3); // 2 is 0010, type indicator for reals
        return $bdata.strrev(pack("d", (float)$val));
    }
780551
protected function doSerialize($val) {
		if(is_string($val) || is_numeric($val) || is_bool($val) || is_null($val))
			return $val;
		else
			return serialize($val);
	}
24602
protected function IDiv( $val )
	{
		return Integer::FromValue( floor( Convert::ToInt( $this->_value /  Convert::ToInt16( $val->getValue() ) ) ) );
	}
1134071
public static function EqValues( $val1, $val2, &$res )
	{
		$res = false;

		if ( ! $val1 instanceof ValueProxy )
		{
			/**
			 * @var ValueProxyFactory $f
			 */
			$class = Type::FromValue( $val1 )->getFullName();
			$f = isset( ValueProxy::$valueFactory[ $class ] )
				? ValueProxy::$valueFactory[ $class ]
				: null;

			if ( is_null( $f ) ) return false;
			$val1 = $f->Create( $val1 instanceof XPath2Item ? $val1->getTypedValue() : $val1 );
		}

		if ( ! $val2 instanceof ValueProxy )
		{

			/**
			 * @var ValueProxyFactory $f
			 */
			$class = Type::FromValue( $val2 )->getFullName();
			$f = isset( ValueProxy::$valueFactory[ $class ] )
				? ValueProxy::$valueFactory[ $class ]
				: null;

			if ( is_null( $f ) ) return false;
			$val2 = $f->Create( $val2 instanceof XPath2Item ? $val2->getTypedValue() : $val2 );
		}

		switch ( ValueProxy::$conv_t[ $val1->GetValueCode() ][ $val2->GetValueCode() ] )
		{
			case -1:
				return $val2->Promote( $val1 )->TryEq( $val2, $res );

			case 0:
				return $val1->TryEq( $val2, $res );

			case 1:
				return $val1->TryEq( $val1->Promote( $val2 ), $res );

			default:
				if ( ValueProxy::$conv_t[ $val2->GetValueCode() ][ $val1->GetValueCode() ] == 1 )
					return $val2->Promote( $val1 )->TryEq( $val2, $res );
				return false;
		}
	}
138820
protected function serializedValue($val)
    {
        if (is_scalar($val)) {
            return $val;
        } elseif ($val instanceof DateTimeInterface) {
            return $val->format('Y-m-d H:i:s');
        } else {
            return json_decode(json_encode($val), true);
        }
    }
1184205
public function inputVal($val, array $options = [])
    {
        $val = $this->dateTimeVal($val);

        if ($val instanceof DateTimeInterface) {
            return $val->format('Y-m-d H:i:s');
        } else {
            return '';
        }
    }
1194588
protected function Eq( $val )
	{
		if ( ! $val instanceof BoolProxy ) return false;
		return  ( $this->_value instanceof CoreFuncs::$False && $val->getValue() instanceof CoreFuncs::$False ) ||
				( $this->_value instanceof CoreFuncs::$True && $val->getValue() instanceof CoreFuncs::$True ) ||
				( is_bool( $this->_value ) && is_bool( $val->getValue() ) && $this->_value == $val->getValue() );
		// return $this->_value == (bool)$val->_value;
	}
92546
function val($val = null){
		if (isset($val) ) {
			if (is_numeric($val) && is_int($val*1)) {
				$this->val = intval($val);
			} else {
				throw new \SimplOn\DataValidationException($this->validationNaN);
			}
		} else {
			return $this->val;
		}
    }
79434
private function encodeValue($val, $base)
    {
        $this->preOpMethodParamsCheck(array($val, $base));

        $digits = $this->baseCheck($base);

        try {

            $new = '';

            while ($this->math->comp($val, '0') > 0) {
                $qq  = $this->math->div($val, $base);
                $rem = $this->math->mod($val, $base);
                $val = $qq;
                $new = $new . $digits[$rem];
            }

            return $new;

        } catch (\Exception $e) {
            throw $e;
        }
    }
1251240
public function boolToBinary($val)
    {
        $saved_object_count = $this->writtenObjectCount++;
        $this->objectTable[$saved_object_count] = $val ? "\x9" : "\x8"; // 0x9 is 1001, type indicator for true; 0x8 is 1000, type indicator for false
        return $saved_object_count;
    }
740041
public function storageVal($val)
    {
        if ($val === null || $val === '') {
            // Do not encode NULL values
            return null;
        }

        if ($val instanceof Translation) {
            $val = (string)$val;
        }

        if (!is_scalar($val)) {
            return json_encode($val, JSON_UNESCAPED_UNICODE);
        }

        return $val;
    }
1286698
protected function Div($val)
	{
		$result = DecimalValue::FromValue( $this->_value )->Div( $val->getValue() );
		return new DecimalProxy( $result );
	}
779231
public function storageVal($val)
    {
        $mode = $this->storageMode();

        if ($mode === self::STORAGE_MODE_INT) {
            return $this->intVal($val);
        } else {
            return $this->stringVal($val);
        }
    }
1122942
protected function IDiv($val)
	{
		return Integer::FromValue( floor( $this->_value->getValue() / Convert::ToInt64( $val->getValue()->getValue() ) ) );
	}
582778
protected function Mul( $val )
	{
		if ( ! $val instanceof ByteProxy ) throw new \InvalidArgumentException();
		return new IntProxy( $this->_value * $val->_value );
	}
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) );
	}