• Status: Solved
• Priority: Medium
• Security: Public
• Views: 188

# Range of double

Hi,

This is about the range of data type double. What will be maximum possible  value that could be assigned to a double type from a long int  without loss of data.

Thank you
mnopix
0
mnopix
• 2
1 Solution

Commented:
Double precision values with double type have 8 bytes. The format is similar to the float format except that it has an 11-bit excess-1023 exponent and a 52-bit mantissa, plus the implied high-order 1 bit. This format gives a range of approximately 1.7Eā308 to 1.7E+308 for type double.

Microsoft Specific ā>

The double type contains 64 bits: 1 for sign, 11 for the exponent, and 52 for the mantissa. Its range is +/ā1.7E308 with at least 15 digits of precision.

END Microsoft Specific
0

Author Commented:
Hi nonubik,
Thank u for explaining the inner storage details of double.
Let me explain my problem  a bit more:
What will be maximum possible  value that could be assigned to a double type from a long int  without loss of data.

long longVal = xx;
double doubleVal;

doubleVal = longVal ; // what will be the max val that could be assigned without loss of data.
i.e the maximum I can keep safely in longVal(xx). Pls give it in a non scientific notation.
0

Commented:
long is represented on 4 bytes, with a range from ā2,147,483,648 to 2,147,483,647
So, any long val can be represented on a double (because double has 15 digits precision and long can have only 13 digits)
0

## Featured Post

• 2
Tackle projects and never again get stuck behind a technical roadblock.