Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Hive float datatype issue !!!

avatar
Explorer

Hello, i'm currently using CDH 5.2

 

I've a sample data like this :

0
18.6
36.1
53.7
86.5

but when i'm upload to hive with float type, i got this :

0.0

18.6000003815

36.0999984741

53.7000007629

86.5

I don't understand why 18.6 become 18.6000003815 , but 86.5 is still the same, every other variable is change except the .0 and .5 varible.

 

Can someone explain to me, really appreciate the help, thanks !

1 ACCEPTED SOLUTION

avatar
Rising Star

This behavior is like any system with float representation, float bit representation does not allow exact representation of most values.  There is a lot of literature on the subject like  http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

 

If you want exact values it's better to go with decimal, where you can specify scale and precision.

 

Thanks

Szehon

View solution in original post

1 REPLY 1

avatar
Rising Star

This behavior is like any system with float representation, float bit representation does not allow exact representation of most values.  There is a lot of literature on the subject like  http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

 

If you want exact values it's better to go with decimal, where you can specify scale and precision.

 

Thanks

Szehon