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

Document FLOAT -> INT casting behavior #18272

Open
mgartner opened this issue Feb 2, 2024 · 0 comments
Open

Document FLOAT -> INT casting behavior #18272

mgartner opened this issue Feb 2, 2024 · 0 comments
Assignees

Comments

@mgartner
Copy link
Contributor

mgartner commented Feb 2, 2024

Marcus Gartner (mgartner) commented:

We recently fixed an incompatibility with Postgres with the behavior of casting a FLOAT to an INT. The fix will be included in v24.1. See cockroachdb/cockroach#117798.

We should document the behavior of these casts. Specifically, a FLOAT to INT cast rounds the float to the nearest integer. If it is equidistant to two integers, it is rounded to the even integer. For example:

SELECT f::INT FROM (VALUES (-1.5::FLOAT), (-0.5::FLOAT), (0.5::FLOAT), (1.5::FLOAT)) v(f);
--  f
-- ----
--  -2
--   0
--   0
--   2
-- (4 rows)

Jira Issue: DOC-9622

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