hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yuzhou Sun (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HIVE-17724) Cast from string to float gives strange result
Date Sat, 07 Oct 2017 01:07:08 GMT

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

Yuzhou Sun commented on HIVE-17724:
-----------------------------------

+1 think it's a limitation of the type

According to https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types and https://en.wikipedia.org/wiki/Single-precision_floating-point_format
, FLOAT is 4-byte single precision floating point number, which uses 8 bits for the exponent

Transfer the numbers to binary number:
1507284611 -> 1011001110101110101011010000011
1507284608 -> 1011001110101110101011010000000


> Cast from string to float gives strange result
> ----------------------------------------------
>
>                 Key: HIVE-17724
>                 URL: https://issues.apache.org/jira/browse/HIVE-17724
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 1.1.0
>         Environment: Hive 1.1.0-cdh5.10.0
> Subversion file:///data0/jenkins/workspace/generic-package-ubuntu64-14-04/CDH5.10.0-Packaging-Hive-2017-01-20_11-52-43/hive-1.1.0+cdh5.10.0+859-1.cdh5.10.0.p0.71~trusty
-r Unknown
>            Reporter: David Scarlatti
>
> this query:"select CAST ('1507284611' as int), CAST ('1507284611' as bigint),  CAST ('1507284611'
as float),   CAST ('1507284611' as double),   CAST ('1507284611' as decimal)"
> returns
> 1507284611	1507284611	1507284608	1507284611	1507284611
> cast as float is the only one changing the numeric value.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message