Question:
C++ - Largest Storable Decimal Number?
Nope
2008-03-13 19:35:59 UTC
I am writing a program where I need a very large number with a decimal, one that is larger than what a Float can handle (I'm sorry I can't be more specific about exact length or number of digits).

Would a Long Double have more precision?

Also, if it does, what is the largest number you can store in a Long Double? All the information I can find on it is in terms of bytes, but like 1 byte is 8 bits and if they were all 1's that would be 255 I believe, so what's the biggest number storable in the variable that would give me the most precision?

I hope I made that clear enough, let me know if I didn't.
Five answers:
The Phlebob
2008-03-13 20:15:23 UTC
As far as I know, there's no absolute definition for the size of any C/C++ type. The ANSI standard had to accommodate too many different C and C++ implementations to be able to force that. In general, though, a float is always equal to or smaller than a double which is in turn always equal to or smaller than a long double. Depending on the implementation, a float, double and long double could even be the same size.



Microsoft Visual C/C++ uses this implementation:



float 4 bytes3.4E +/- 38 (7 digits)

double 8 bytes 1.7E +/- 308 (15 digits)

long double 8 bytes 1.7E +/- 308 (15 digits)



Hope that helps.
2008-03-14 02:43:50 UTC
One byte is 255, 2 bytes is 65535, etc.



You can't store a decimal in a long, because a long is an integer value (no decimals).



If there's no data type large enough for your use, you'll have to write your own multi-precision math routines.
2008-03-14 02:44:25 UTC
Largest float == 3.40282e+38

Smallest float == 1.17549e-38

Largest double == 1.79769e+308

Smallest double == 2.22507e-308

Largest long double == 1.18973e+4932

smallest long double == 3.3621e-4932



Largest char == 

Smallest char == ?

Largest int == 2147483647

Smallest int == -2147483648

Largest short == 32767

Smallest short == -32768



Largest Unsigned (int) == 4294967295

Smallest Unsigned (int) == 0

Largest Long (int) == 2147483647 (2 ^ 31)

Smallest Long (int) == -2147483648



Hope you find this useful!!
Balk
2008-03-14 02:42:50 UTC
A LONG DOUBLE is the same as a DOUBLE.



Here's a table of the C/C++ data types:

http://msdn2.microsoft.com/en-us/library/s3f49ktz(VS.80).aspx



-
?
2013-11-15 12:34:29 UTC
welll .'' for Intiger Value ( no fractional part ) , " uint64_t " type varible can store upto 20 digit value !! , i.e 64 bit ''


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Search results for 'C++ - Largest Storable Decimal Number?' (Questions and Answers)
3
replies
c++-largest storable integer number.?
started 2012-02-16 09:29:54 UTC
programming & design
Loading...