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
2
votes
1 answer

Nasm: how to load a long double into the FPU from memory

I am writing a function in nasm that will be called from 32bit ansi C. The function prototype in C looks like this: long double scalar(int n, long double *x) Where x is a pointer to an array of long doubles. The problem occurs when I try to load a…
Jan Grz
  • 1,373
  • 14
  • 18
2
votes
3 answers

Define LDBL_MAX/MIN on C

I'm working with C, I have to do an exercise in which I have to print the value of long double min and long double max. I used float.h as header, but these two macros (LDBL_MIN/MAX) give me the same value as if it was just a double. I'm using Visual…
Tsurupeta
  • 63
  • 1
  • 8
2
votes
1 answer

How can I move an 80-bit floating point number with double precision from memory to XMM0 in AT&T assembly

I've written an AT&T assembly function to calculate an integral. I need to pass it as a return value as it's called by code written in C. I've successfully managed to return it as a single precision float and a double precision double. But I know I…
bowl
  • 559
  • 6
  • 12
2
votes
1 answer

Why these two snippets generate different value?

When I run the following code: #include int main() { int i = 0; volatile long double sum = 0; for (i = 1; i < 50; ++i) /* first snippet */ { sum += (long double)1 / i; } printf("%.20Lf\n", sum); sum =…
nalzok
  • 14,965
  • 21
  • 72
  • 139
2
votes
1 answer

C - long double and printf issue

I am new C programmer and I am working on a school project where I have to approximate the value or pi. My professor stated that we have to declare all integer terms using long double. The console shows me asking the user for the number of terms to…
Jai Mehra
  • 21
  • 2
2
votes
2 answers

Longdouble(1e3000) becomes inf: What can I do?

(Most other related questions in the web concern conversion between C's longdouble and python's. This question is different.) I do not see why I cannot correctly get a longdouble in python like this: In [72]: import numpy as np In [73]:…
zell
  • 9,830
  • 10
  • 62
  • 115
2
votes
2 answers

GCC: Restrict long double width

Is there a way/switch to restrict the size of long doubles to 64 bits when compiling using GCC?
Pascal Kesseli
  • 1,620
  • 1
  • 21
  • 37
2
votes
3 answers

how to use more precision in c++

Hi i have built an algorithm to calculate pi but i use long float for it so i just get 3.14159 as a result, i need more precision. How? here is the code: #include #include using namespace std; int main () { long double a,…
2
votes
1 answer

Why is my C++ program so slow when switching from long double to float128?

I program on Unix, using the g++ 4.8.2 compiler. I currently need to convert my C++ program, which at this point uses long double (with a significand of 64 bits in my case), to a program which uses the __float128 type (with a significand of 113…
2
votes
1 answer

Alternative to long double which has the same Precision on Windows and Unix?

I'm programming a Tool which allows you to convert a given Numbers (Dec, Bin, Hex) in a specific Date Format (Unix Time, HFS, Fat-Time,...) into an human readable date-string. I have a problem with Windows OLE-Date, which represents the Date and…
user2071938
  • 2,055
  • 6
  • 28
  • 60
2
votes
2 answers

Adding long doubles gives the wrong answer in C++

I have a section of code that reads: std::cerr << val1 << " " << val2 << std::endl; val1 = val1 + val2; std::cerr << val1 << std::endl; Both val1 and val2 are long double. The problem comes from the fact that the result of this…
Andrew Spott
  • 3,457
  • 8
  • 33
  • 59
1
vote
3 answers

Integer constant is too large for its type AND invalid operands to binary operators

I'm using double long in my 64 bit computer and sizeof(double long) is 16 bytes. So I do the following assignment: long double f = 0xA0000000000000000000000000000000; // 32 characters in hex and I get this warning: warning: integer constant is…
Fooko R.
  • 129
  • 1
  • 10
1
vote
1 answer

Precision long double worse than double

When I use long double I get worse precision than using double. 3.14159265358979323846264L is this good to write long double const in source code or I should add something other than L? EDIT I solved the problem. I change algorithm to be more…
Bla bla
  • 111
  • 2
  • 8
1
vote
0 answers

A problem in saving "long double" variables to hdf5 file

I'm new to hdf5. I'm trying to save the results of a simulation in hdf5 file. The variables are long double. So, I mapped them into NATIVE_LDOUBLE. However, the saved values are completely wrong (fluctuating between very small and very large…
FeyPhys
  • 25
  • 4
1
vote
3 answers

Converting long double in .NET

I have to convert some C code (that ran in a Linux machine) to .Net, and found some operations with long double. They are not special operations, just some multiplications and divisions that end with a lot of decimals, it seems the type was used…
Neverbirth
  • 1,044
  • 8
  • 20