Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round function is not working as expected #91316

Closed
vishalatul09 mannequin opened this issue Mar 30, 2022 · 2 comments
Closed

round function is not working as expected #91316

vishalatul09 mannequin opened this issue Mar 30, 2022 · 2 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@vishalatul09
Copy link
Mannequin

vishalatul09 mannequin commented Mar 30, 2022

BPO 47160
Nosy @tirkarthi
Files
  • compiled_result.jpg: compiled result
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-03-30.11:04:59.302>
    created_at = <Date 2022-03-30.10:45:33.440>
    labels = ['3.7', 'invalid', 'type-bug', 'library']
    title = 'round function is not working as expected'
    updated_at = <Date 2022-03-30.11:04:59.300>
    user = 'https://bugs.python.org/vishalatul09'

    bugs.python.org fields:

    activity = <Date 2022-03-30.11:04:59.300>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-30.11:04:59.302>
    closer = 'xtreak'
    components = ['Library (Lib)']
    creation = <Date 2022-03-30.10:45:33.440>
    creator = 'vishalatul09'
    dependencies = []
    files = ['50707']
    hgrepos = []
    issue_num = 47160
    keywords = []
    message_count = 2.0
    messages = ['416333', '416337']
    nosy_count = 2.0
    nosy_names = ['xtreak', 'vishalatul09']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue47160'
    versions = ['Python 3.7']

    @vishalatul09
    Copy link
    Mannequin Author

    vishalatul09 mannequin commented Mar 30, 2022

    round function is not working as expected .
    my number is x= 0.967565*185000= 178999.525
    round(x,2)
    answer is coming as 178999.52
    expected value is 178999.53

    @vishalatul09 vishalatul09 mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 30, 2022
    @tirkarthi
    Copy link
    Member

    This is documented

    https://docs.python.org/3/library/functions.html#round

    The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. See Floating Point Arithmetic: Issues and Limitations for more information.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant