You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Yongjun Zhang (JIRA)" <ji...@apache.org> on 2018/09/13 21:00:00 UTC

[jira] [Comment Edited] (IMPALA-6202) fmod and mod and % are not equivalent

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

Yongjun Zhang edited comment on IMPALA-6202 at 9/13/18 8:59 PM:
----------------------------------------------------------------

Hi [~jbapple],

Thanks for finding the issue and creating the jira.

I assume fmod()'s behavior is as expected:
{code:java}
[localhost:21000] default> select fmod(9.9, 3);
+--------------------+
| fmod(9.9, 3)       |
+--------------------+
| 0.8999996185302734 |
+--------------------+
[localhost:21000] default> select typeof(fmod(9.9, 3));
+----------------------+
| typeof(fmod(9.9, 3)) |
+----------------------+
| FLOAT                |
+----------------------+
{code}
So what we need to fix is:
 # # the functionality of mod().
 # the doc of fmod().

Do you agree?

If so, we can create a separate Jira to do #2, and let this Jira address #1. Does that sound good?

Thanks.


was (Author: yzhangal):
Hi [~jbapple],

Thanks for finding the issue and creating the jira.

I assume fmod()'s behavior is as expected:
{code}
[localhost:21000] default> select fmod(9.9, 3);
+--------------------+
| fmod(9.9, 3)       |
+--------------------+
| 0.8999996185302734 |
+--------------------+
[localhost:21000] default> select typeof(fmod(9.9, 3));
+----------------------+
| typeof(fmod(9.9, 3)) |
+----------------------+
| FLOAT                |
+----------------------+
{code}
So what we need to fix is:

# # the functionality of mod(). 
# the doc of fmod().

Do you agree?

Thanks.

> fmod and mod and % are not equivalent
> -------------------------------------
>
>                 Key: IMPALA-6202
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6202
>             Project: IMPALA
>          Issue Type: Bug
>    Affects Versions: Impala 2.11.0
>            Reporter: Jim Apple
>            Assignee: Yongjun Zhang
>            Priority: Major
>
> The docs say:
> "mod(numeric_type a, same_type b) Purpose: Returns the modulus of a number. Equivalent to the % arithmetic operator."
> and
> "fmod(double a, double b), fmod(float a, float b) Purpose: Returns the modulus of a floating-point number. Equivalent to the % arithmetic operator."
> But these can't both be true:
> {noformat}
> [localhost:21000] > select typeof(9.9 % 3), typeof(mod(9.9, 3)), typeof(fmod(9.9, 3));
> +-----------------+---------------------+----------------------+
> | typeof(9.9 % 3) | typeof(mod(9.9, 3)) | typeof(fmod(9.9, 3)) |
> +-----------------+---------------------+----------------------+
> | DECIMAL(2,1)    | DECIMAL(4,1)        | FLOAT                |
> +-----------------+---------------------+----------------------+
> {noformat}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org