Casts the internal value to an integer cmprehended between a range of
accepted integers.

@return integer
173160
public function castDecimal()
    {
        $min   = (float) 4.9E-324;
        $max   = (float) 1.7976931348623157E+308;
        $value = (float) $this->value;

        if ($value >= $min && $value <= $max) {
            return $value;
        }

        $castFunction = function($value) use ($min,$max) {
            if ($value < $min ) {
                return $min;
            }

            if ($value > $max) {
                return $max;
            }

            return (float) $value;
        };

        if (is_numeric($this->value)) {
            return $castFunction($this->value);
        }

        return $this->handleMismatch($castFunction, 'decimal');
    }
489455
public function get()
    {
        if ($this->isInteger()) {
            /** @noinspection PhpUndefinedMethodInspection */
            return $this->value['num']->get();
        }

        $num = intval(gmp_strval($this->value['num']->gmp()));
        $den = intval(gmp_strval($this->value['den']->gmp()));

        return $num/$den;
    }
430049
public function readInt()
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        $buf = @fread($this->fp, 4);

        return (ord($buf[0]) + (ord($buf[1]) << 8) +
            (ord($buf[2]) << 16) + (ord($buf[3]) << 24));
    }
1161310
public function asInteger(): Primitive\Integer
    {
        if (!$this->_element instanceof Primitive\Integer) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_INTEGER));
        }
        return $this->_element;
    }
54436
final public function ordinal(): int
    {
        if ($this->ordinal === null) {
            $ordinal = 0;
            foreach (self::getMembers() as $constValue) {
                if ($this->value === $constValue) {
                    break;
                }
                $ordinal++;
            }
            $this->ordinal = $ordinal;
        }

        return $this->ordinal;
    }
693170
public Integer asIntegerObj() {
		if (current == null)
			return null;
		if (current instanceof Number) {
			if (current instanceof Integer)
				return (Integer) current;
			if (current instanceof Long) {
				Long l = (Long) current;
				if (l.longValue() == l.intValue()) {
					return Integer.valueOf(l.intValue());
				}
			}
			return null;
		}
		return null;
	}
895669
public int intValue() {
		int value;
		value = Integer.parseInt(this.param);
		if(this.isNeg) value = (-value);
		return value;
	}
583233
private function decodeInteger()
    {
        $offsetOfE = strpos($this->source, "e", $this->offset);
        if (false === $offsetOfE) {
            throw new RuntimeException("Unterminated integer entity at offset $this->offset");
        }

        $currentOffset = $this->offset;
        if ("-" == $this->getChar($currentOffset)) {
            ++$currentOffset;
        }

        if ($offsetOfE === $currentOffset) {
            throw new RuntimeException("Empty integer entity at offset $this->offset");
        }

        while ($currentOffset < $offsetOfE) {
            if (!ctype_digit($this->getChar($currentOffset))) {
                throw new RuntimeException("Non-numeric character found in integer entity at offset $this->offset");
            }
            ++$currentOffset;
        }

        $value = substr($this->source, $this->offset, $offsetOfE - $this->offset);

        // One last check to make sure zero-padded integers don't slip by, as
        // they're not allowed per bencode specification.
        $absoluteValue = (string) abs($value);
        if (1 < strlen($absoluteValue) && "0" == $value[0]) {
            throw new RuntimeException("Illegal zero-padding found in integer entity at offset $this->offset");
        }

        $this->offset = $offsetOfE + 1;

        // The +0 auto-casts the chunk to either an integer or a float(in cases
        // where an integer would overrun the max limits of integer types)
        return $value + 0;
    }
23571
protected function convertValue()
    {
        $values = array();

        if (is_array($this->getValue())) {
            $values = array_map('intval', $this->getValue());
        } elseif ($this->getValue() != null) {
            $values[] = (int) $this->getValue();
        }

        return $values;
    }
547503
public function getAsNativeType()
    {
        if ($this->isInteger()) {
            return intval($this->value['num']->get());
        }

        return floatval($this->value['num']->get() / $this->value['den']->get());
    }
751977
final public function readInt32BE()
    {
        if ($this->isLittleEndian()) {
            return $this->fromInt32(strrev($this->read(4)));
        } else {
            return $this->fromInt32($this->read(4));
        }
    }
416300
public function count()
    {
        if(is_null($this->int_count)){
            $this->int_count = mb_strlen($this->value, C::ENCODING);
        }

        return $this->int_count;
    }
1085458
public function toMicro()
    {
        $inner = $this->getAttribute("amount", false); //cast=false
        $decimals = $this->getDivisibility();

        if (is_integer($inner)) {
            $attrib = $inner;
        }
        elseif (is_float($inner)) {
            // we want only integer!
            $attrib = $inner * pow(10, $decimals);
        }
        elseif (is_string($inner)) {
            // parse number string representation. Parsing to float.
            $isFloat = false !== strpos($inner, ".");
            $number = $isFloat ? (float) $inner : (int) $inner;
            $multi  = $isFloat ? pow(10, $decimals) : 1;
            $attrib = $number * $multi;
        }
        elseif (is_array($inner)) {
            // try to read first value of array
            $attrib = array_shift($inner);
        }
        else {
            $attrib = (int) $inner;
        }

        $this->micro = (int) $attrib;
        if ($this->micro < 0)
            // not allowed: 0 in micro XEM is the minimum possible value!
            $this->micro = 0;

        return $this->micro;
    }
133331
public function castValue($value)
    {
        if ($value === 'Off' || $value === '' || $value === 0 || $value === '0' || $value === false) {
            $casted = 0;
        } elseif ($value === 'On' || $value === '1' || $value === 1) {
            $casted = 1;
        } else {
            $casted = $value;
        }

        $casted = $this->castPowers($casted);

        return $casted;
    }
467863
public function readInt()
    {
        $str = $this->_fread(4);

        return  ord($str[0]) << 24 |
                ord($str[1]) << 16 |
                ord($str[2]) << 8  |
                ord($str[3]);
    }
601545
public function getCasts()
    {
        if ($this->incrementing && !$this->uuid){
            return array_merge([
                $this->getKeyName() => 'int',
            ], $this->casts);
        }

        return $this->casts;
    }
357612
public function parse(): int
    {
        // convert constants to ints
        $this->expression = $this->convertErrorConstants($this->expression);
        $this->expression = str_replace(
            [',', ' '],
            ['.', ''],
            $this->expression
        );

        return $this->compute($this->expression);
    }