Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

in hive casting of decimal to double is returning the exponential form rather than the non scientific form

Highlighted

in hive casting of decimal to double is returning the exponential form rather than the non scientific form

New Contributor

hive> select cast(12345678910.231 as double);

1.2345678910231E10

Time taken: 0.164 seconds, Fetched: 1 row(s)

but need the value 12345678910.231 stored as double.

select cast(cast(12345678910.231 as double) as double); also wont work and is similar as the above.

I dont need the output format to be change using the printf() UDF, rather i need the value to be stored and retrieved while querying as a non exponential form.

2 REPLIES 2

Re: in hive casting of decimal to double is returning the exponential form rather than the non scientific form

Expert Contributor
@sai harshavardhan

The value that you are receiving is as expected, this sample java code show the info. If you are wanting to get the exact value as an output, you should convert that value to string.

import java.lang.*;

public class DoubleDemo

{

public static void main(String[] args)

{

double d = 12345678910.231;

System.out.println("Value of d = " + d);

}

}

Re: in hive casting of decimal to double is returning the exponential form rather than the non scientific form

New Contributor

Hi Team,

You can cast as decimal and solve the issue as shown below. ROUND(CAST(1.750646377E7 AS DECIMAL(38,10)),2);

Thanks & regards,

Kamleshkumar Gujarathi