Skip to content

Should the docstring for div clarify floating-point behaviour as in fld? #55837

@Sagnac

Description

@Sagnac

At least until div is fixed for floats (#49561).

At the moment the docstrings for div refer only to integers, but there's no type restriction on the inputs which leads to a discrepancy if called with floats:

julia> div(1.0, 0.1, RoundToZero)
9.0

julia> round(1.0 / 0.1, RoundToZero)
10.0

This is of course because decimals such as 0.1 don't have an exact floating-point representation so the result can differ when rounded down; the docstring for fld includes this warning, but div does not, so even simple operations such as 1.0 ÷ 0.1 can lead to unintuitive results if this is not specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentationmathsMathematical functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions