Skip to main content
gamedev.net
🔒 Locked

long double

Started by Dave007 Dec 1, 2001 at 4:49 AM 6 replies 200+ views
Original Post
Dave007
Dave007
Hi! does anyone know how to property use the C++''s long double variable type. ...if I use the "long double a;" declaration it always behaves like only double. Thnx Dave007
dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System
Anon Mike
Anon Mike
I don''t think long double is even a standardized type. It''s probably treated similiarly to "long int" - that is, it must be at least as big as the base type (double in your case) but there''s no guarantee it will be any bigger.

-Mike
-Mike
python_regious
python_regious
double - 8 byte double precision floating point variable
long double - 10 byte extended precision floating point variable

I think thats right...
If at first you don't succeed, redefine success.
Dave007
Dave007
Yes, long double has extrended precision and it''s range is about +-1e4907 (I guess) .. but double "only" about +-1e307 ... so if I try to use long double the result is always truncated to the double precision. I dunno why.

Dave007
dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System
python_regious
python_regious
It may be that some other code you are using takes doubles, and you pass a long double, so it''s being truncated. I doubt the standard console output ( cout and printf ) have support for displaying extended precision numbers. The math library *only* uses double precision. So you may be using the extended precision, but you can only output in double precision. Just a thought...
If at first you don't succeed, redefine success.
python_regious
python_regious
I just found a few MSDN pages about long doubles:

quote:
The long double contains 80 bits: 1 for sign, 15 for exponent, and 64 for mantissa. Its range is +/–1.2E4932 with at least 19 digits of precision. Although long double and double are separate types, the representation of long double and double is identical.


I also found this about long doubles too:

quote:

Previous 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported the long double, 80-bit precision data type. In Win32 programming, however, the long double data type maps to the double, 64-bit precision data type. The Microsoft run-time library provides long double versions of the math functions only for backward compatibility. The long double function prototypes are identical to the prototypes for their double counterparts, except that the long double data type replaces the double data type. The long double versions of these functions should not be used in new code.



Edited by - python_regious on December 2, 2001 9:51:04 AM
If at first you don't succeed, redefine success.
Dave007
Dave007
It''s very interesting when the long double type can''t be used, when Delphi has the Extended type which is equivalent to the long double and it works corretly.

Dave007
dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.