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

162 questions
0
votes
2 answers

machine epsilon - long double in c++

I wanted to calculate the machine Epsilon, the smallest possible number e that gives 1 + e > 1 using different data types of C++: float, double and long double. Here's my code: #include template T machineeps() { T epsilon =…
bambuk
  • 1
  • 1
  • 1
0
votes
4 answers

Objective C: Creating Long Double uses Decimal Method

How do I create the following method? I have tried to use modf(n, 1) or modf(n, 2) but those both return an error of "Passing argument 2 of modf makes pointer from integer without a cast. Heres the method: (BOOL) numberHasDecimal: (long double) n…
michaellindahl
  • 2,012
  • 5
  • 36
  • 64
0
votes
2 answers

C long double in golang

I am porting an algorithm from C to Go. And I got a little bit confused. This is the C function: void gauss_gen_cdf(uint64_t cdf[], long double sigma, int n) { int i; long double s, d, e; //Calculations ... for (i = 1; i < n - 1;…
user5817854
0
votes
2 answers

Appending long double literal suffix to user inputs in c++

I have a class that has a long double vector: MyClass{ vector myvec; public: MyClass(){ //Constructor } // Some memeber functions that operate on the vector }; I have overloaded the input operator an I'm taking…
Anjoys
  • 89
  • 10
0
votes
0 answers

C - Long double min and max value

Is correct that min and max value of a long double are like double ones? They use 8 byte each other and max arrive at about E308 (10^308). Long double should use 16byte and arrive at >E4000, shouldn't it? Or it depends from the computer? I check…
Gianmi
  • 11
  • 2
0
votes
2 answers

Output long double to console

I tried to output a long double to the console directly using qDebug() and indirectly via QString::number() but both do not accept long double. Is it true that there is no easy way of printing a long double floating point number to the console using…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
0
votes
1 answer

If I'm trying to replicate a program in another language. Is it unwise to use more precision?

I'm in the process of converting a program from Scilab code to C++ and it's essential for me to maintain the results produced by Scilab. I'm aware that Scilab uses IEEE 754 double precision and that C++ doubles (although not required to) are…
Paul Warnick
  • 903
  • 2
  • 13
  • 26
0
votes
1 answer

returns long double instead of double

I am writing a program in c++ where I want to find the epsilon of my pc. I want the result to be double precision (which is 2.2204460492503131 E-16) but instead the output is 1.0842 E-019 which is the epsilon in long double precision. My program is…
Jon Snow
  • 101
0
votes
1 answer

Format specifier %Lf for long double in C is not working as if expected

While studying the C essentials from online video, the author shared the code below to find the difference between float, double and long double. I ran this program in Eclispse running in 64 bit Windows 10 Laptop. #include #include…
0
votes
1 answer

Long double reseting to 0 after assignment

I've been tinkering around with some disease models in C/C++ and would like to get more precision out of it. I thought about using long doubles, for the 80-bit precision (I'm using cygwin`s GCC 4.8.3), but after making a calculation with it, I get a…
Pedro
  • 333
  • 1
  • 5
  • 24
0
votes
3 answers

What is wrong with this expression? "if (factorarray[x]%2 == 0 && factorarray[x]%3 ==0..."

Here is the code: #include #include #include using namespace std; class Project3 { public: void factorcalc() { while (i<5000000){ ++i; factor = prime/i; if (factor…
0
votes
0 answers

How can I change the displayed value of a double when outputting to the console in Eclipse Kepler, C++, (mac OS X)?

Here is my code: #include #include using namespace std; class Project3 { public: long double divbythree() { while (i
0
votes
0 answers

print long double on windows

I use Microsoft Visual Studio 2010 and Intel C++ Compiler XE 14.0. Project configuration is ‘x64’. I need to work with the long double data type. I added a compile option /Qlong_double and wrote a test example: long double ld = 2; long…
Konstantin Isupov
  • 199
  • 1
  • 2
  • 12
0
votes
3 answers

Using strtol to get long double in c++

I am trying to get the long double out of an array. long double num; char * pEnd; char line[] = {5,0,2,5,2,2,5,4,5,.,5,6,6}; num = strtold(line1, &pEnd); For some reason the num i am getting is rounded to 502522545.6 I am quite new to C++…
olv1do
  • 13
  • 1
  • 5
0
votes
3 answers

how to parse a long double from scientific notation

I have a text file with numbers in scientific notation stored as a string of characters, some of which have up to 20 digits. For example, 2.3456789e-015. I need to convert this into a long double in order to perform some mathematical operations on…
oneb1got
  • 153
  • 1
  • 4
  • 8
1 2 3
10
11