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

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

Open
Sagnac opened this issue Sep 22, 2024 · 0 comments · May be fixed by #55918
Open

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

Sagnac opened this issue Sep 22, 2024 · 0 comments · May be fixed by #55918
Labels
domain:docs This change adds or pertains to documentation domain:maths Mathematical functions

Comments

@Sagnac
Copy link
Contributor

Sagnac commented Sep 22, 2024

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.

Sagnac added a commit to Sagnac/julia that referenced this issue Sep 28, 2024
Closes JuliaLang#55837

This is a variant of the warning found in the `fld` docstring
clarifying floating-point behaviour.
@Sagnac Sagnac linked a pull request Sep 28, 2024 that will close this issue
@nsajko nsajko added domain:docs This change adds or pertains to documentation domain:maths Mathematical functions labels Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation domain:maths Mathematical functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants