Integer Methods

int.as_integer_ratio()

Represent an integer exactly as a rational pair. The numerator is the original integer and the denominator is always 1, including for zero and negative integers. No floating-point conversion is needed. This method shares an interface with float.as_integer_ratio().

Formal Syntax & Structure

python syntaxpython
value.as_integer_ratio()

Return Value

tuple[int, int]

Exact numerator and positive denominator.

Working Example

Example Snippetpython
count = -125print(count.as_integer_ratio())print((10**30).as_integer_ratio())
Python Reference