Questions tagged [long-double]

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).

143 questions
74
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
  • 14,204
  • 29
  • 102
  • 157
63
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,385
  • 3
  • 14
  • 16
33
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
  • 61,669
  • 16
  • 122
  • 172
28
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,594
  • 4
  • 19
  • 27
26
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
  • 369,957
  • 201
  • 546
  • 842
23
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
  • 27,667
  • 11
  • 72
  • 104
20
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
  • 357
  • 2
  • 7
  • 17
15
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
  • 123,396
  • 14
  • 248
  • 352
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,217
  • 9
  • 46
  • 73
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,034
  • 6
  • 17
10
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
  • 50,257
  • 51
  • 171
  • 339
6
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
  • 195,354
  • 31
  • 331
  • 669
6
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
  • 8,226
  • 7
  • 41
  • 91
6
votes
5 answers

x86-64 long double precision

What is the actual precision of long double on Intel 64-bit platforms? is it 80 bits padded to 128 or actual 128 bit? if former, besides going gmp, is there another option to achieve true 128 precision?
Anycorn
  • 46,748
  • 41
  • 153
  • 250
6
votes
1 answer

How do I use the numpy longdouble dtype?

I am trying to work with the np.longdouble dtype in my Python code, and am trying to use NumPy to manipulate long doubles that I get from a C module compiled with Cython. Suppose I do this: import numpy as np print np.finfo(np.longdouble) Machine…
Abhinav
  • 258
  • 1
  • 6
  • 17
1
2 3
9 10