Convert float to int

On ARM CPUs converting floats to ints doesn't always work

@access private
@param string $x
@return int
183472
function safe_intval($x)
    {
        switch (true) {
            case is_int($x):
            // PHP 5.3, per http://php.net/releases/5_3_0.php, introduced "more consistent float rounding"
            case (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
                return $x;
        }
        return (fmod($x, 0x80000000) & 0x7FFFFFFF) |
            ((fmod(floor($x / 0x80000000), 2) & 1) << 31);
    }
744059
public function intVal(): int
    {
        if (!isset($this->_intNum)) {
            $num = gmp_init($this->_num, 10);
            if (gmp_cmp($num, $this->_intMaxGmp()) > 0) {
                throw new \RuntimeException("Integer overflow.");
            }
            if (gmp_cmp($num, $this->_intMinGmp()) < 0) {
                throw new \RuntimeException("Integer underflow.");
            }
            $this->_intNum = gmp_intval($num);
        }
        return $this->_intNum;
    }
1107615
public function computeVarintSize($value)
    {
        if (($value & (0xffffffff <<  7)) === 0) {
            return 1;
        }

        if (($value & (0xffffffff << 14)) === 0) {
            return 2;
        }

        if (($value & (0xffffffff << 21)) === 0) {
            return 3;
        }

        if (($value & (0xffffffff << 28)) === 0) {
            return 4;
        }

        if (($value & (0xffffffff << 35)) === 0) {
            return 5;
        }

        if (($value & (0xffffffff << 42)) === 0) {
            return 6;
        }

        if (($value & (0xffffffff << 49)) === 0) {
            return 7;
        }

        if (($value & (0xffffffff << 56)) === 0) {
            return 8;
        }

        if (($value & (0xffffffff << 63)) === 0) {
            return 9;
        }

        return 10;
    }
198830
public function multiply(self $x)
    {
        $value = gmp_mul($this->value, $x->value);

        return self::createFromGMPResource($value);
    }
7962
public void appendInt(int x) {
        elems = ArrayUtils.ensureCapacity(elems, length + 3);
        elems[length  ] = (byte)((x >> 24) & 0xFF);
        elems[length+1] = (byte)((x >> 16) & 0xFF);
        elems[length+2] = (byte)((x >>  8) & 0xFF);
        elems[length+3] = (byte)((x      ) & 0xFF);
        length = length + 4;
    }
580145
public static function int_add($x, $y)
    {
        if ($y == 0) {
            return $x;
        } else {
            return self::int_add($x ^ $y, ($x & $y) << 1);
        }
    }
1258174
public function get(int $x, int $y) : bool
    {
        $offset = $y * $this->rowSize + ($x >> 5);
        return 0 !== (BitUtils::unsignedRightShift($this->bits[$offset], ($x & 0x1f)) & 1);
    }
493505
public static function is_valid_number(string $x) : bool {
        $ap = new qtype_numerical_answer_processor(array());
        list($value, $unit) = $ap->apply_units($x);
        return !is_null($value) && !$unit;
    }
985635
public function setX($x)
    {

        $this->x = MathUtil::capValue($x, 0, XyzColorInterface::REF_X);

        return $this;
    }
1038524
public function getX() : ?int 
    {
        if ( ! $this->hasX()) {
            $this->setX($this->getDefaultX());
        }
        return $this->x;
    }
1279811
protected function cast($value)
    {
        if (strlen($value) === 0) {
            return null;
        }
        if ($this->getScale() === 0) {
            return (int)$value;
        }
        return (float)$value;
    }
257927
private function convertInt($value)
    {
        if (!is_numeric($value)) {
            return $value;
        }

        if ((string) (int) $value !== (string) $value) {
            return $value;
        }

        return (int) $value;
    }
105153
private void xdr_int(int i) {
    buffer[offset++] = (byte)((i >> 24) & 0xff);
    buffer[offset++] = (byte)((i >> 16) & 0xff);
    buffer[offset++] = (byte)((i >> 8) & 0xff);
    buffer[offset++] = (byte)(i & 0xff);
  }
4165
public function pixelIndex(Int $x, Int $y) : Int
    {
        return imagecolorat($this->canvas, $x, $y);
    }
1099469
public static function convertToBytes(string $value): int
    {
        $units = "BKMGT";
        $unit = preg_replace("/[^$units]/i", "", $value);
        $value = floatval($value);
        if ($unit) {
            $value *= pow(1024, stripos($units, $unit[0]));
        }

        return (int) $value;
    }
965630
protected function setX($x)
	{
		if ( ! is_numeric($x) || $x < 0)
		{
			throw new \InvalidArgumentException('The value of x must be a positive numeric.');
		}
		
		$this->x = (int) $x;
		
		return $this;
	}
250080
@Pure
	public double toGlobalX(double x) {
		final double adjustedX = x - this.translationX.get();
		return this.invertX.get() ? -adjustedX : adjustedX;
	}