Skip to main content

float_as_int

Converts a floating-point number to an integer by truncating the decimal portion.

def float_as_int(
value: float
) - > int

Converts a floating-point number to an integer by truncating the decimal part. Use this when you need to ensure a value is an integer type for operations that do not accept floats, such as list indexing or range boundaries.

Parameters

NameTypeDescription
valuefloatThe floating-point number to be converted into an integer.

Returns

TypeDescription
intThe integer representation of the input value after removing all fractional digits.