[
https://issues.apache.org/jira/browse/CASSANDRA-18647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17742050#comment-17742050
]
Stefan Miklosovic commented on CASSANDRA-18647:
-----------------------------------------------
3.11
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2680/workflows/3b05e246-e4af-494f-9156-7b74e66dd053
4.0 j8
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2671/workflows/09167497-d534-4117-b365-cb397a2286f2
4.0 j11
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2671/workflows/baff69d8-9852-4eae-8a4b-794977ef7e27
4.1 j8
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2670/workflows/b5748f43-d164-4106-a6c6-32c213886800
4.1 j11
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2670/workflows/1d5cbfb7-6470-4ea3-b7e5-ba00ff03d4d9
trunk j8
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2646/workflows/10c901f0-f355-45f2-b9d1-9bbf240aa077
trunk j11
https://app.circleci.com/pipelines/github/instaclustr/cassandra/2646/workflows/424918c6-5630-4a99-8521-cc73ef80be44
> CASTing a float to decimal adds wrong digits
> --------------------------------------------
>
> Key: CASSANDRA-18647
> URL: https://issues.apache.org/jira/browse/CASSANDRA-18647
> Project: Cassandra
> Issue Type: Bug
> Components: CQL/Semantics
> Reporter: Nadav Har'El
> Assignee: Stefan Miklosovic
> Priority: Normal
> Fix For: 5.x
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> If I create a table with a *float* (32-bit) column, and cast it to the
> *decimal* type, the casting wrongly passes through the double (64-bit) type
> and picks up extra, wrong, digits. For example, if we have a column e of type
> "float", and run
> INSERT INTO tbl (p, e) VALUES (1, 5.2)
> SELECT CAST(e AS decimal) FROM tbl WHERE p=1
> The result is the "decimal" value 5.199999809265137, with all those extra
> wrong digits. It would have been better to get back the decimal value 5.2,
> with only two significant digits.
> It appears that this happens because Cassandra's implementation first
> converts the 32-bit float into a 64-bit double, and only then converts that -
> with all the silly extra digits it picked up in the first conversion - into a
> "decimal" value.
> Contrast this with CAST(e AS text) which works correctly - it returns the
> string "5.2" - only the actual digits of the 32-bit floating point value are
> converted to the string, without inventing additional digits in the process.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]