简体   繁体   English

将 bigint 转换为 hive 中的科学数

[英]coverting bigint into scientific number in hive

I am trying to convert bigint to scientific number in hive using cast function as below我正在尝试使用如下强制转换函数将 bigint 转换为 hive 中的科学数

select cast(805454539 as float) from table name;

Above query is giving me 805454528以上查询给了我 805454528

However, I am looking for something like 8.05454539E8但是,我正在寻找类似8.05454539E8东西

To convert float to scientific notation string representation you can use printf() function (8 in this example - is the number of decimal places):要将浮点数转换为科学记数法字符串表示形式,您可以使用 printf() 函数(本例中为 8 - 是小数位数):

select printf('%1.8e',cast(805454539 as double))

result:结果:

8.05454539e+08

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM