Class: QgsMathUtils

Contains utility functions for mathematical operations.

Added in version 4.0.

Static Methods

doubleToRational

Converts a double value to a rational fraction.

class qgis.core.QgsMathUtils[source]

Bases: object

static doubleToRational(value: float, tolerance: float = 1e-09, maxIterations: int = 100)[source]

Converts a double value to a rational fraction.

Parameters:
  • value (float) – value to convert

  • tolerance (float = 1e-09) – desired precision. The returned fraction will be at within this tolerance of the original value.

  • maxIterations (int = 100) -> (int) – maximum number of iterations. Higher values result in better approximations, but at the cost of additional computation.

Returns:

  • numerator: calculated numerator

  • denominator: calculated denominator