[ 
https://issues.apache.org/jira/browse/CASSANDRA-11935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16634224#comment-16634224
 ] 

Benedict commented on CASSANDRA-11935:
--------------------------------------

bq. Stuff involving floats or doubles is lossy

This is untrue.  Only *some* things involving floats and doubles are lossy.  
Integer operations on values smaller than the significand's precision are 
lossless, for instance.  This means that if for {{float + int}} we used 
{{double}} the operation would not be inherently lossy - in fact for a wide 
range of values this would be lossless (not just integer operations).  
Similarly for a {{double + bigint}} and {{decimal}}.

The most surprising part of this behaviour, however, is that simply adding 
{{0.0f}} to any value greater than {{2^24}} will result in an answer that has 
changed for no readily apparent reason.  The integer is immediately truncated 
to its nearest float value, which is incapable of representing it.

FWIW, it might be that we are OK with this imprecision, but we should at least 
consider the behaviour, and then document it clearly.

> Add support for arithmetic operators
> ------------------------------------
>
>                 Key: CASSANDRA-11935
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11935
>             Project: Cassandra
>          Issue Type: Sub-task
>          Components: CQL
>            Reporter: Benjamin Lerer
>            Assignee: Benjamin Lerer
>            Priority: Major
>             Fix For: 4.0
>
>
> The goal of this ticket is to add support for arithmetic operators:
> * {{-}}: Change the sign of the argument
> * {{+}}: Addition operator
> * {{-}}: Minus operator
> * {{*}}: Multiplication operator
> * {{/}}: Division operator
> * {{%}}: Modulo operator
> This ticket we should focus on adding operator only for numeric types to keep 
> the scope as small as possible. Dates and string operations will be adressed 
> in follow up tickets.
> The operation precedence should be:
> # {{*}}, {{/}}, {{%}}
> # {{+}}, {{-}}
> Some implicit data conversion should be performed when operations are 
> performed on different types (e.g. double + int).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to