Match integer or float token and return value

@return int|float
@throws UnexpectedValueException
972416
private function number()
    {
        // If next token is a float match and return it
        if ($this->lexer->isNextToken(Lexer::T_FLOAT)) {
            return $this->match(Lexer::T_FLOAT);
        }

        // If next token is an integer match and return it
        if ($this->lexer->isNextToken(Lexer::T_INTEGER)) {
            return $this->match(Lexer::T_INTEGER);
        }

        // Throw exception since no match
        throw $this->syntaxError('CrEOF\Geo\String\Lexer::T_INTEGER or CrEOF\Geo\String\Lexer::T_FLOAT');
    }
1327749
def value_is_int(self):
        """"""
        try:
            a = float(self.value)
            b = int(a)
        except ValueError:
            return False
        else:
            return a == b
932766
function Check($value)
    {
        if (!ctype_digit(Str::TrimLeft($value, '-')))
            $this->error = self::HasNonDigits;
        else
        {
            $floatValue = (float)$value;
            if ($floatValue < $this->min)
            {
                 $this->error = self::ExceedsMin;
            }
            else if ($floatValue > $this->max)
                $this->error = self::ExceedsMax;
        }
        return $this->error == '';
    }
1111863
public function getAmount() : ?float 
    {
        if ( ! $this->hasAmount()) {
            $this->setAmount($this->getDefaultAmount());
        }
        return $this->amount;
    }
438437
protected int getIntValue() {
		if (label.equals(AbcTokens.DIGIT)
				|| label.equals(AbcTokens.DIGITS)) {
			try {
				return Integer.parseInt(value);
			} catch (NumberFormatException nfe) {
				return -1;
			}
		}
		else
			return -1;
	}
1016298
private function castValue(string $value)
    {
        $value = $this->normalize($value);
        if (\preg_match('/^[0-9]+$/', $value)) {
            $value = (int)$value;
        } elseif (\preg_match('/^[0-9\.]+$/', $value)) {
            $value = (float)$value;
        } elseif (\preg_match('/^true|false$/', $value)) {
            $value = $value === 'true' ? true : false;
        }
        return $value;
    }
126769
private function getNumericValue(string $value)
    {
        if (\strpos($value, '.') !== false) {
            return (float) $value;
        }

        return (int) $value;
    }
1186530
function cast($val) {
		if (preg_match('/^(?:0x[0-9a-f]+|0[0-7]+|0b[01]+)$/i',$val))
			return intval($val,0);
		if (is_numeric($val))
			return $val+0;
		$val=trim($val);
		if (preg_match('/^\w+$/i',$val) && defined($val))
			return constant($val);
		return $val;
	}
12615
private function return_($value) {
        if (abs($value) === INF) {
            return $value;
        } else if ($value === 'INF') {
            return INF;
        } else if ($value === '-INF') {
            return -INF;
        } else {
            return (float) $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;
    }
1181723
public function getFloatValue()
    {
        list($quotient, $remainder) = $this->big_integer->divide(self::precisionUnitsAsBigInt(1, $this->precision));
        return floatval($quotient->toString()) + floatval($remainder->toString() / pow(10, $this->precision));
    }
32136
protected function checkType($value)
    {
        if ($value === null) {
            return $value;
        }

        Type::force($value, 'numeric', true);
        return $value === null ? $value : (float)$value;
    }
1082308
def value(self):
        
        if self.opts['int']:
            return int(self.val)
        else:
            return float(self.val)
379721
public function asOctetString(): Primitive\OctetString
    {
        if (!$this->_element instanceof Primitive\OctetString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_OCTET_STRING));
        }
        return $this->_element;
    }
1345021
private function _parseAttrTypeAndValue(int &$offset): array
    {
        $idx = $offset;
        $type = $this->_parseAttrType($idx);
        $this->_skipWs($idx);
        if ($idx >= $this->_len || "=" != $this->_dn[$idx++]) {
            throw new \UnexpectedValueException("Invalid type and value pair.");
        }
        $this->_skipWs($idx);
        // hexstring
        if ($idx < $this->_len && "#" == $this->_dn[$idx]) {
            ++$idx;
            $data = $this->_parseAttrHexValue($idx);
            try {
                $value = Element::fromDER($data);
            } catch (DecodeException $e) {
                throw new \UnexpectedValueException(
                    "Invalid DER encoding from hexstring.", 0, $e);
            }
        } else {
            $value = $this->_parseAttrStringValue($idx);
        }
        $offset = $idx;
        return array($type, $value);
    }
906931
private function compare_float( $a, $b ) {
		$a = number_format( $a, 4 );
		$b = number_format( $b, 4 );
		if ( 0 === $a - $b ) {
			return 0;
		} elseif ( $a - $b < 0 ) {
			return -1;
		} else {
			return 1;
		}
	}
832129
public function coerce($value): int
    {
        if ($value === '') {
            throw new InvalidTypeException('Int cannot represent non 32-bit signed integer value: (empty string)');
        }

        if (\is_bool($value)) {
            $value = (int)$value;
        }

        if (!\is_numeric($value) || $value > PHP_INT_MAX || $value < PHP_INT_MIN) {
            throw new InvalidTypeException(
                \sprintf('Int cannot represent non 32-bit signed integer value: %s', $value)
            );
        }

        $floatValue = (float)$value;

        if ($floatValue != $value || \floor($floatValue) !== $floatValue) {
            throw new InvalidTypeException(\sprintf('Int cannot represent non-integer value: %s', $value));
        }

        return (int)$value;
    }