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

Extension functions for rounding #193

Open
JimLarson opened this issue Apr 18, 2021 · 0 comments
Open

Extension functions for rounding #193

JimLarson opened this issue Apr 18, 2021 · 0 comments

Comments

@JimLarson
Copy link
Contributor

PR #192 corrects the spec to match the implementations by doing floating point to integer conversion via truncation (round towards zero). Other rounding behaviors are sometimes useful.

Create an extension library for mathematics, e.g. math.*(), with at least the following functions:

  • math.ceil(double) -> int: rounds towards infinity
  • math.floor(double) -> int: rounds toward negative infinity
  • math.round(double) -> int: rounds "half away", i.e. rounds toward nearest integer, breaking ties by rounding away from zero.

More behaviors are possible if needed, though this seems unlikely. See https://en.wikipedia.org/wiki/Rounding

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
@JimLarson and others