Solved

Range of double

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft vcsetup.exe and vcssetup.exe 8 421
linker errors gone with a clean build 2 52
AVI wait icons for CAnimateCtrl in Visual Studio 2008 MFC 1 132
Infragistics Ultragrid 3 105
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

12 Experts available now in Live!

Get 1:1 Help Now