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

Convert double to integer via truncation. #192

Merged
merged 3 commits into from
Jun 2, 2021

Conversation

JimLarson
Copy link
Contributor

Matches behavior of C, Go, and Java.

Introduce a round() function for round-half-away like GoogleSQL.

Fixes #191

Matches behavior of C, Go, and Java.

Introduce a round() function for round-half-away like GoogleSQL.
doc/langdef.md Outdated
@@ -2070,7 +2070,8 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9).
(double) -> int
</td>
<td>
type conversion
Type conversion. Rounds toward zero, then errors if result is out of
range. See also round().
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's introduce round, floor, and ceil into a math namespace in a separate PR.
e.g. math.round(double), etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Defer round() until another PR.
@JimLarson
Copy link
Contributor Author

PTAL

@JimLarson
Copy link
Contributor Author

Filed Issue #193 as a reminder to implement the math extension library with alternate ways of rounding.

@TristonianJones TristonianJones merged commit 8ff24ba into google:master Jun 2, 2021
sthagen added a commit to sthagen/google-cel-spec that referenced this pull request Jul 16, 2021
Convert double to integer via truncation. (google#192)
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

Successfully merging this pull request may close these issues.

Standardize double-to-integer conversion via truncation
2 participants