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
1
vote
4 answers
Has "long double" a single word name?
Many new C++ data type names have a single word name,
for example:
int16_t instead of signed short int
int64_t instead of signed long long int
...
Has "long double" a single word name?

Amir Saniyan
- 13,014
- 20
- 92
- 137
1
vote
2 answers
The precision of the long double output is not correct. What might be wrong?
I have a long double constant that I am setting either as const or not-const. It is longer (40 digits) than the precision of a long double on my test workstation (19 digits).
When I print it out, it no longer is displayed at 19 digits of precision,…

Alex Reynolds
- 95,983
- 54
- 240
- 345
1
vote
0 answers
Why 16-byte alignment for `long double`?
64 bit architecture like x86-64 have word size of 64bits. In this case, if a memory access crosses over the word boundary, then it will require double the time to access data. So alignment is required. - This is what I know. Correct me if I am…

Sourav Kannantha B
- 2,860
- 1
- 11
- 35
1
vote
1 answer
What is the correct way to get the binary representation of long double?
Here's my attempt:
#include
union newType {
long double firstPart;
unsigned char secondPart[sizeof(firstPart)];
} lDouble;
int main() {
lDouble.firstPart = -16.5;
for (int_fast16_t i { sizeof(lDouble) - 1 }; i…

Xofrio
- 15
- 2
1
vote
0 answers
Unexpected answer in c++
i wrote this code in c++. i expect 4932.08 for the answer(calculated by calculator)
#include
#include
#include
using namespace std;
int main()
{
long double a;
a = LDBL_MAX;
cout << "log10(" << a…

Saman
- 11
- 5
1
vote
1 answer
How to enable long double in Intel ICC
I'm on MacOS, and am following the guide Using the Intel® Math Library to implement the first example:
// real_math.c
#include
#include
int main() {
float fp32bits;
double fp64bits;
long double fp80bits;
long double…

Seva Safris
- 401
- 4
- 12
1
vote
2 answers
How to print long double number in xinu?
Function sqrtl doesn't work here, also the printf of long double prints f for all given numbers:
#include
#include
#include
#include
long double sqrtn;
unsigned long int n;
void xmain() {
unsigned…

reham.abass
- 15
- 5
1
vote
1 answer
Alignment when using a long double in a structure
I know in general, a struct instance will have the alignment of its widest scalar member. I declared a structure having a member of long double data type.
struct try
{
char a;
long double b;
};
struct try obj;
When i tried to check…

LocalHost
- 910
- 3
- 8
- 24
1
vote
2 answers
How to convert long double to char[12]?
Given long double, I need to serialize it to char[12] (optimally) and deserialize.
Is it even possible?

Commander Tvis
- 2,244
- 2
- 15
- 41
1
vote
2 answers
Wrong C++ long double min/max values using numeric_limits in Visual Studio 2019
Using Visual Studio Community 2019 v16.4.2 with the latest stuff it comes with on 64bit Win10.
While testing various datatype limits ran into a weird bug, numeric_limits can't distinguish between double and long double min/max values. Displays more…

deVoid
- 13
- 4
1
vote
0 answers
c++ calculation of long doubles giving inf or zero
so I created a program that takes in two long double numbers and some a particular form of calculation on them. but the issue is, the output for me is inf or in some compilers, 0..
So the error only occurs when I enter exponential values like say I…

Jim Kelly
- 11
- 3
1
vote
0 answers
Testing data types. I am trying to use double long float. it outputs 0
Very basic, asking user to input double float amongst other data
types. long double is outputed as 0.
i tried checking for logic errors, found none.
long double example;
printf("please enter a very big float\n");
scanf("%Lf",&example);
printf("your…

xganh zu
- 25
- 6
1
vote
1 answer
Reading a long double into R
Is it not possible to read a long double from a text file into R? I've looked at the packages like bit64, gmp, float and others but they all seem to manage large doubles internally.
Note, I am not referring to a display ("options(digits=22)")…

algae
- 407
- 4
- 15
1
vote
0 answers
A Long double variable results in a negative number when a value is assigned
The issue I am having is that when I define a variable n as long double and set the value to 5 when i run it to print the value of n it prints -0.0000. I'm trying to achieve a larger range of numbers so i decided to switch from double to long…

Mr Alam
- 19
- 2
1
vote
2 answers
Detect long double overflows on embedded systems
I'm going to use big numbers in C++ code on an embedded system. Luckily the compiler recognizes long doubles.
I can not use standard libraries, boost libraries, gnu math libraries, etc. And the system has not got built-in float math cpu.
Now how can…

Hossein
- 4,097
- 2
- 24
- 46