Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue with Round Function in Python #123811

@lykan89

Description

@lykan89

Bug report

Bug description:

Description of the Issue:
The round function does not seem to handle certain floating-point numbers correctly. For example, when rounding the number -1357.1357 to negative 4 decimal places, the function returns -0.0 instead of the expected 0.0.

Steps to Reproduce:

  1. Open a Python interpreter.
  2. Execute the following code:
print(round(-1357.1357, -4))
  1. Observe the output.

Expected Result: The output should be 0.0.
Actual Result: The output is -0.0.

Environment Details Tested:
--Python Version: 3.12.5, Operating System: Windows 11.
--Python Version: 3.12.3, Operating System: Ubuntu.

Additional Information: I have verified this issue on multiple machines and with different Python versions. The issue persists across all tested environments.

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions