Questions related to `long double` floating-point data-type (numbers) as commonly found in languages like C and C++. Sometimes referred to as quadruple-precision floating-point data-type (numbers).
Questions tagged [long-double]
162 questions
82
votes
3 answers
long double vs double
I know that size of various data types can change depending on which system I am on.
I use XP 32bits, and using the sizeof() operator in C++, it seems like long double is 12 bytes, and double is 8.
However, most major sources states that long double…

CppLearner
- 16,273
- 32
- 108
- 163
68
votes
8 answers
printf and long double
I am using the latest gcc with Netbeans on Windows. Why doesn't long double work? Is the printf specifier %lf wrong?
Code:
#include
int main(void)
{
float aboat = 32000.0;
double abet = 5.32e-5;
long double dip = 5.32e-5;
…

gameboy
- 1,505
- 3
- 15
- 16
41
votes
4 answers
long double (GCC specific) and __float128
I'm looking for detailed information on long double and __float128 in GCC/x86 (more out of curiosity than because of an actual problem).
Few people will probably ever need these (I've just, for the first time ever, truly needed a double), but I…

Damon
- 67,688
- 20
- 135
- 185
37
votes
3 answers
Difference between long double and double in C and C++
Possible Duplicate:
long double vs double
I am new to programming and I am unable to understand the difference between between long double and double in C and C++. I tried to Google it but was unable to understand it and got confused. Can anyone…

user1543957
- 1,758
- 4
- 20
- 30
29
votes
2 answers
What is the precision of long double in C++?
Does anyone know how to find out the precision of long double on a specific platform? I appear to be losing precision after 17 decimal digits, which is the same as when I just use double. I would expect to get more, since double is represented…

Bill the Lizard
- 398,270
- 210
- 566
- 880
27
votes
1 answer
Why did Microsoft abandon long double data type?
A while ago I wrote a program which used some factorial functions. I used the long double data type to support "relative" big numbers.
Now, I changed from codeblocks to Visualstudio 2010, I was wondering why my program didn't work any more till I…

Stephan Dollberg
- 32,985
- 16
- 81
- 107
25
votes
5 answers
Why would you use float over double, or double over long double?
I'm still a beginner at programming and I always have more questions than our book or internet searches can answer (unless I missed something). So I apologize in advance if this was answered but I couldn't find it.
I understand that float has a…

floatfil
- 407
- 2
- 10
- 17
16
votes
5 answers
What are the applications/benefits of an 80-bit extended precision data type?
Yeah, I meant to say 80-bit. That's not a typo...
My experience with floating point variables has always involved 4-byte multiples, like singles (32 bit), doubles (64 bit), and long doubles (which I've seen referred to as either 96-bit or 128-bit).…

gnovice
- 125,304
- 15
- 256
- 359
13
votes
4 answers
sizeof long double and precision not matching?
Consider the following C code:
#include
int main(int argc, char* argv[])
{
const long double ld = 0.12345678901234567890123456789012345L;
printf("%lu %.36Lf\n", sizeof(ld), ld);
return 0;
}
Compiled with gcc 4.8.1 under…

Vincent
- 57,703
- 61
- 205
- 388
10
votes
2 answers
Why are double and long double completely the same on my 64 bit machine?
This question may sound like for beginners, however when I found that out I thought I'm either a beginner or my comp is missing something:
int main()
{
cout << sizeof(double) << endl;
cout << sizeof(long double) << endl;
cout << DBL_DIG…

codekiddy
- 5,897
- 9
- 50
- 80
10
votes
4 answers
Union not reinterpreting values?
Consider this program:
#include
union myUnion
{
int x;
long double y;
};
int main()
{
union myUnion a;
a.x = 5;
a.y = 3.2;
printf("%d\n%.2Lf", a.x, a.y);
return 0;
}
Output:
-858993459
3.20
This is fine, as…

DarkAtom
- 2,589
- 1
- 11
- 27
8
votes
4 answers
Convert extended precision float (80-bit) to double (64-bit) in MSVC
What is the most portable and "right" way to do conversion from extended precision float (80-bit value, also known as long double in some compilers) to double (64-bit) in MSVC win32/win64?
MSVC currently (as of 2010) assumes that long double is…
user313885
7
votes
3 answers
Largest integer that can be stored in long double
EDIT: After some discussion in the comments it came out that because of a luck of knowledge in how floating point numbers are implemented in C, I asked something different from what I meant to ask.
I wanted to use (do operations with) integers…

anotherOne
- 1,513
- 11
- 20
7
votes
2 answers
long double math library implementations?
What are the available portable implementations of the C99 long double math library functions (expl, cosl, logl, etc.), if any? I've looked in fdlibm (Sun-based), NetBSD (UCB-based), etc. sources and not seen them.

R.. GitHub STOP HELPING ICE
- 208,859
- 35
- 376
- 711
7
votes
2 answers
How to get a Python long double literal?
How to get a Python long double literal? I have tried with
numpy.longdouble(1e309)
and
numpy.longdouble("1e309")
but both of them just return inf. What would be the right way to do that?
[EDIT] An answer below says that long double is treated as…

zell
- 9,830
- 10
- 62
- 115