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
4
votes
2 answers
How to force long double in Perl
I lose precision when doing arithmetic or trying to print (debug) numbers this big:
1234567890.123456789
I think my problems are with $d (result of arithmetic) and the formatted print of $e.
How can I force long doubles? My Perl version (5.8.4 on…

dnvrdave
- 117
- 2
- 7
4
votes
1 answer
How do I force usage of long doubles with Cython?
I apologize in advance for my poor knowledge of C: I use Python to code and have written a few modules with Cython using the standard C functions to effect a great increase in speed. However, I need a range higher than 1e308 (yes, you read it…

Abhinav
- 268
- 1
- 7
- 19
4
votes
3 answers
confusion with data structure allignment?
Code 1:-
struct emp
{
char a;
double b;
};
int main()
{
struct emp e;
printf("%p %p", (void*)&e.a, (void*)&e.b);
}
Output on my computer:-
OO28FF00 0028FF08
As the size of char and double is '1' and '8' respectively and hence the…

kevin gomes
- 1,775
- 5
- 22
- 30
3
votes
1 answer
Why doesn't long double have more precision than double?
I want to check the largest integer that can be held in various floating-point types in C without loss of precision. Here is a test program:
#include
#include
#include
#define FLOATTYPE long double
#define ONE…

Ed Wynn
- 295
- 1
- 8
3
votes
1 answer
Compiling Windows C++ application with long doubles in VS2010
At work we have MSVS2010 Ultimate, and I'm writing a program which runs exhaustive simulations using real numbers. I'm getting non-trivial round-off errors and I've already taken reasonable steps to ensure my algorithm is as numerically stable as…

Ozzah
- 10,631
- 16
- 77
- 116
3
votes
1 answer
Long double and Intellisense in Visual Studio
As you know long double is identical to double in Visual Studio, unfortunately. However the intellisense feature shows a different story. For example check out the following code;
#include
#include
using namespace std;
int…

Kitiara
- 343
- 6
- 21
3
votes
1 answer
How to disable long double in boost::math?
I have c++ source file, example.cpp, using some boost::math functions.
My boost library is also built.
To disable long double in boost::math, I did the following:
g++ -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS example.cpp -I…

Armstrong
- 33
- 4
3
votes
0 answers
Wrong output when printing long double with printf in mingw
I was trying to use long doubles in a bigger code but even this doesn't seem to work.
#include
#include
int main(){
long double I = 10.0;
long double YOU = 2.0;
long double WE = I/YOU;
printf("%Lf", I);
…

XxCharbonChainsxX
- 87
- 6
3
votes
1 answer
what is the exact range of long double in c++?
I've been googling for hours and still can't find the exact results of "what is the range of long double in c++". some say long double is the same as double. but sizeof double is 8 bytes and sizeof long double is 16 bytes. note that I'm using gcc.

user135142
- 135
- 9
3
votes
1 answer
Get the digits of a long double
I am trying to implement a simple version of a function similar to dtoa but without arbitrary precision. I name it ftob which also handles arithmetic bases other than 10 (2-36). It works with long double, which on my machine is : x86 extended…

Siddharth Bhat
- 57
- 7
3
votes
1 answer
Favorite/Best A.X=B Solver that Supports Long Doubles?
I am hoping to repeatedly hammer an X=B(A^-1) problem. That is, solve a linear system. For C++, which numerical solvers have support for 128bit long doubles (quads)?
Using C style arrays is a major plus as all my 2D data is stored as a single…

Mikhail
- 7,749
- 11
- 62
- 136
3
votes
1 answer
Crazy behaviour during execution
I have been doing some inline-asm with gcc. Everything is ALMOST working, up to some behaviour that is just baffling me. I am evaluating a rational polynomial, but need to use 80-bit constants. The generated code seems to be perfect, but on…

David I. McIntosh
- 31
- 4
3
votes
1 answer
Microsoft's edX C++ course: double vs long double - why a lack of common standard?
I decided to go through Microsoft's C++ course on edX.
According to them, double and long double are identical in size and range:
This contradicts these specs: https://en.wikipedia.org/wiki/C_data_types
At first, I thought Microsoft make a typo,…

InfiniteLoop
- 387
- 1
- 3
- 18
3
votes
4 answers
How to convert a NSString to long double?
I am dealing with a long double value that can have huge values.
At one time I have this number represented as NSString and I need to convert it to long double. I see that the only API I have is
[myString doubleValue];
I don't see a…

Duck
- 34,902
- 47
- 248
- 470
3
votes
3 answers
Python: reading float80 values
I have an array of 10-bytes (80-bits) Little Endian float values (or float80). How can i read this values in python 3?
The package struct does not support float80 (may be I read the docs carelessly).
The package array as same as package "struct"…

kai3341
- 89
- 7