Solved

Range of double

Posted on 2004-10-06
3
182 Views
Last Modified: 2010-04-24
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
Comment
Question by:mnopix
  • 2
3 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 12237819
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 Comment

by:mnopix
ID: 12248982
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
 
LVL 16

Accepted Solution

by:
nonubik earned 30 total points
ID: 12249065
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question