Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

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
Asked:
mnopix
  • 2
1 Solution
 
nonubikCommented:
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
 
mnopixAuthor 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
 
nonubikCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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