INT

Casts a floating point value to an integer

Excel Function:
INT(number)

@access    public
@category Mathematical and Trigonometric Functions
@param    float    $number            Number to cast to an integer
@return    integer    Integer value
19566
public static function INT($number)
    {
        $number    = PHPExcel_Calculation_Functions::flattenSingleValue($number);

        if (is_null($number)) {
            return 0;
        } elseif (is_bool($number)) {
            return (int) $number;
        }
        if (is_numeric($number)) {
            return (int) floor($number);
        }
        return PHPExcel_Calculation_Functions::VALUE();
    }
562443
private function getValue($value)
    {
        if ($this->isBoolean($value)) {
            return (strtolower($value) === 'true');
        } elseif ($this->isInteger($value)) {
            return (int)$value;
        } elseif ($this->isNumber($value)) {
            return (float)$value;
        }
        return $value;
    }
213211
public static function toNumber($o)
    {
        if (is_int($o) === true || is_float($o) === true) {
            return $o;
        } else {
            if (is_bool($o) === true) {
                return ($o) ? 1 : 0;
            } elseif (is_numeric($o) === true && $o !== "") {
                return ($o + 0);
            }

            return null;
        }
    }
430219
public function base10($number)
    {
        if (!is_int($number)) {
            throw new \InvalidArgumentException('Expecting integer');
        }

        if ($this->integerPart === '0' && !$this->fractionalPart) {
            return $this;
        }

        $sign = '';
        $integerPart = $this->integerPart;

        if ($integerPart[0] === '-') {
            $sign = '-';
            $integerPart = substr($integerPart, 1);
        }

        if ($number >= 0) {
            $integerPart = ltrim($integerPart, '0');
            $lengthIntegerPart = strlen($integerPart);
            $integers = $lengthIntegerPart - min($number, $lengthIntegerPart);
            $zeroPad = $number - min($number, $lengthIntegerPart);

            return new self(
                $sign.substr($integerPart, 0, $integers),
                rtrim(str_pad('', $zeroPad, '0').substr($integerPart, $integers).$this->fractionalPart, '0')
            );
        }

        $number = abs($number);
        $lengthFractionalPart = strlen($this->fractionalPart);
        $fractions = $lengthFractionalPart - min($number, $lengthFractionalPart);
        $zeroPad = $number - min($number, $lengthFractionalPart);

        return new self(
            $sign.ltrim($integerPart.substr($this->fractionalPart, 0, $lengthFractionalPart - $fractions).str_pad('', $zeroPad, '0'), '0'),
            substr($this->fractionalPart, $lengthFractionalPart - $fractions)
        );
    }
211273
public function expandNumber($number)
    {
        switch (strtoupper(substr($number, -1))) {
            case 'B':
                $multiplier = 1000000000;
                break;
            case 'M':
                $multiplier = 1000000;
                break;
            case 'K':
                $multiplier = 1000;
                break;
            default:
                $multiplier = 1;
        }

        return (int) intval($number) * $multiplier;
    }
1039231
public function lengthGreaterThan($number)
    {
        //argument 1 must be numeric
        Argument::i()->test(1, 'numeric');
        
        return strlen((string)$this->value) > (float)$number;
    }
995818
public static function fromNumber($number)
    {
        if (is_float($number)) {
            return self::fromString(sprintf('%.14F', $number));
        }

        if (is_int($number)) {
            return new self($number);
        }

        if (is_string($number)) {
            return self::fromString($number);
        }

        throw new \InvalidArgumentException('Valid numeric value expected');
    }
782530
public static function number($number, $decimals = 0)
    {
        $l = self::getLocale();
        return number_format($number, $decimals, $l->decimalPoint, $l->thousandsSep);
    }
874438
final private static function bcRoundHalfUp($number, $precision)
    {
        return self::truncate(bcadd($number, self::getHalfUpValue($number, $precision), $precision + 1), $precision);
    }
257927
private function convertInt($value)
    {
        if (!is_numeric($value)) {
            return $value;
        }

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

        return (int) $value;
    }
470741
public static function fromFloat($number)
    {
        if (is_float($number) === false) {
            throw new \InvalidArgumentException('Floating point value expected');
        }

        return self::fromString(sprintf('%.14F', $number));
    }
671072
private static function localeNumber($number, int $decimal = 2): string
	{
		return Number::getNumber(self::prepareFloat($number), $decimal);
	}
1240179
public function setNumber($number)
    {
        $this->number = $number;
        $this->factors = $this->getFactors($this->getNumber());
    }
1142080
public static function php_number_format($number)
    {

        preg_match('/[.,](\d+)$/', $number, $matches);

        $num_decimals = strlen($matches[1]);

        return preg_replace('/[.,]/', '', $number) / pow(10, $num_decimals);
    }
927712
public function shortenNumber($number)
    {
        $abbr = [9 => 'B', 6 => 'M', 3 => 'K'];

        foreach ($abbr as $exponent => $suffix) {
            if ($number >= pow(10, $exponent)) {
                return intval($number / pow(10, $exponent)) . $suffix;
            }
        }

        return $number;
    }
1040930
public function number($number, $decimals = 0)
    {
        return number_format(
            (float) $number,
            $decimals,
            $this->get('number')['decimal_separator'],
            $this->get('number')['thousands_separator']
        );
    }
908001
public function convertToDouble($number)
    {
        $number = str_replace(',', '.', (string) $number);

        if (!is_numeric($number)) {
            throw new \UnexpectedValueException("{$number} não é um número válido");
        }

        return (float) number_format($number, 2, '.', '');
    }