Math Functions

math.trunc()

Remove the fractional part by rounding toward zero. May dispatch to __trunc__.

Formal Syntax & Structure

python syntaxpython
math.trunc(x, /)

Parameters & Attributes

NameTypeDescription
xreal numberInput real value.

Return Value

int

An integral result; custom hooks should return an integral value.

Working Example

Example Snippetpython
import mathprint(math.trunc(-3.9))
Python Reference