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

Incorrect documentation for std.math.round/@round #19809

Open
balvaldyr opened this issue Apr 29, 2024 · 1 comment
Open

Incorrect documentation for std.math.round/@round #19809

balvaldyr opened this issue Apr 29, 2024 · 1 comment

Comments

@balvaldyr
Copy link

As per documentation the behaviour is described as such for std.math.round() and @round
https://github.com/ziglang/zig/blob/956f53beb09c07925970453d4c178c6feb53ba70/lib/std/math.zig#L1217C50-L1217C57

/// Rounds the given floating point number to an integer, away from zero.
/// Uses a dedicated hardware instruction when available.
/// This is the same as calling the builtin @round

Based upon the documentation I would expect the following behaviour:

@round(0.4) == 1
@round(-2.3) == -3

However, these @round to 0 and -2 respectively.

Suggestion: Change the documentation to

/// Rounds the given floating point number to the nearest integer, in case of two equidistant integers it rounds away from zero.
/// Uses a dedicated hardware instruction when available.
/// This is the same as calling the builtin @round
@xdBronch
Copy link
Contributor

looks like theres already a pr for this #19503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants