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

Skip to content

Document that float // float returns a float #102823

Closed
@mdickinson

Description

@mdickinson

PEP 238 states clearly that the result of x // y is a float, when x and y both have type float.

For floating point inputs, the result is a float. For example:

3.5//2.0 == 1.0

And indeed this is the behaviour that's been in place since Python 2.2. However, we seem to be missing a clear statement of this in the official docs. It would be good to fix that.

Motivated by the thread https://discuss.python.org/t/make-float-floordiv-and-rfloordiv-return-an-int/24959, where it's been asserted that this behaviour is an 'implementation detail'.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions