int()

The integer part of a numeric value

Synopsis

int(x)

Description

This function returns the integer part of a numerical value. In other words, int(x) returns floor(x) if x is non-negative and ceil(x) if x is negative.

Parameters

x

A numerical expression.

Returns

Returns the integer part of a numerical value.

Examples

my_x = int(2.1 + 1.6)   # my_x = 3
my_x = int(-2.1 - 1.6)   # my_x = -3

See Also

ceil(), floor(), round()