- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Hive float datatype issue !!!
Created on ‎12-17-2014 02:07 AM - edited ‎09-16-2022 02:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 !
Created ‎12-18-2014 09:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎12-18-2014 09:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
