Skip to content

Expected behavior of math.ceil, math.floor, math.trunc, and round #143

@casevh

Description

@casevh

Note: I am specifically discussing float/mpfr inputs.

The behavior of the math.ceil, math.floor, math.trunc, and round changed between Python 2 and Python 3. In Python 2.x, a float was always returned. In Python 3.x, math.ceil, math.floor, and math.trunc return an integer type instead of a floating point type. round returns an integer type if the requested numbers of digits is 0 but returns a floating point type for in the requested number of digits is either greater than 0 or less than 0.

What should gmpy2 2.1 do?

  1. Follow the behavior of the Python version?
  2. Continue to use the Python 2 behavior even in Python 3?
  3. Use the Python 3 behavior on Python 2?
  4. Add a context option to allow the user to select a specific behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions