Solved

Range of double

Posted on 2004-10-06
3
178 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now