Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > range of long double variables

Reply
Thread Tools

range of long double variables

 
 
Leslaw Bieniasz
Guest
Posts: n/a
 
      02-21-2011


Hi,

I have Borland C++Builder 6.0 compiler, and I would be happy
to understand the implementation of long double variables in this
compiler. According to the help files and manuals, long double variables
are implemented using 10 bytes, they are supposed to have 18 significant
digits, and range from (about) 10^(-4932) to 10^(4932).
From my calculations, I see that the accuracy is indeed at this level.
However, I have been unable to perform any operations on numbers greater
than about 10^308, which is the maximum limit for double variables, not
long double. For example, an attempt to substitute:

long double x = 1.e309L;

produces exceptions during program execution.
Does anybody know what is the reason for this behaviour?
Am I possibly doing something wrong? Should I link any special
libraries, choose any special compiler options, or whatever?

Leslaw
 
Reply With Quote
 
 
 
 
jacob navia
Guest
Posts: n/a
 
      02-21-2011
Le 21/02/11 12:00, Leslaw Bieniasz a écrit :
>
>
> Hi,
>
> I have Borland C++Builder 6.0 compiler, and I would be happy
> to understand the implementation of long double variables in this
> compiler. According to the help files and manuals, long double variables
> are implemented using 10 bytes, they are supposed to have 18 significant
> digits, and range from (about) 10^(-4932) to 10^(4932).
> From my calculations, I see that the accuracy is indeed at this level.
> However, I have been unable to perform any operations on numbers greater
> than about 10^308, which is the maximum limit for double variables, not
> long double. For example, an attempt to substitute:
>
> long double x = 1.e309L;
>
> produces exceptions during program execution.
> Does anybody know what is the reason for this behaviour?
> Am I possibly doing something wrong? Should I link any special
> libraries, choose any special compiler options, or whatever?
>
> Leslaw


1) Look at the generated assembler code. Does it use long double
operations?

2) Look at the CPU state: Is in full precision or in double precision only?

If unsure send me the assembler listing and I will tell you.
 
Reply With Quote
 
 
 
 
Juha Nieminen
Guest
Posts: n/a
 
      02-21-2011
jacob navia <> wrote:
> 2) Look at the CPU state: Is in full precision or in double precision only?


I didn't know Intel CPUs need to be in a special state in order to support
extended precision floating point numbers. Are you talking about some
different CPU?
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      02-21-2011
Le 21/02/11 15:33, Juha Nieminen a écrit :
> jacob navia<> wrote:
>> 2) Look at the CPU state: Is in full precision or in double precision only?

>
> I didn't know Intel CPUs need to be in a special state in order to support
> extended precision floating point numbers. Are you talking about some
> different CPU?

The CPU can perform operations in double precision or in native long
double precision.

Microsoft compilers set the precision to double precision at startup,
since they do not support long double, in their implementation
long double is equal to double.

Other compilers like lcc-win or gcc use long double precision and the
startup code (at least in my compiler system lcc-win) sets the CPU
to full precision. This means that sometimes programs may fail that
would work in double precision...

When using double precision only, the CPU discards extra precision.

Normally, gcc startup code sets the CPU in full precision, as in
lcc-win since they support long double.

Now, Borland is difficult to say...

Do they support true long double?

Or do they just accept long double but they convert it to double?

Or they support long double only when some compilation directive
is issued?

If you look at the generated asm code you know what is being used:
double or long double precision...

 
Reply With Quote
 
Geoff
Guest
Posts: n/a
 
      02-21-2011
On Mon, 21 Feb 2011 12:00:29 +0100, Leslaw Bieniasz
<> wrote:

>
>
>Hi,
>
>I have Borland C++Builder 6.0 compiler, and I would be happy
>to understand the implementation of long double variables in this
>compiler. According to the help files and manuals, long double variables
>are implemented using 10 bytes, they are supposed to have 18 significant
>digits, and range from (about) 10^(-4932) to 10^(4932).
>From my calculations, I see that the accuracy is indeed at this level.
>However, I have been unable to perform any operations on numbers greater
>than about 10^308, which is the maximum limit for double variables, not
>long double. For example, an attempt to substitute:
>
>long double x = 1.e309L;
>
>produces exceptions during program execution.
>Does anybody know what is the reason for this behaviour?
>Am I possibly doing something wrong? Should I link any special
>libraries, choose any special compiler options, or whatever?
>
>Leslaw


What is the value of
LDBL_MAX_10_EXP
LDBL_MIN_10_EXP
LDBL_MAX
LDBL_MIN
for your implementation?

Post some sample code showing the behavior you describe?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to ‘(const __gnu_cxx::hash<long long int>) (const long long int&)’ veryhotsausage C++ 1 07-04-2008 05:41 PM
unsigned long long int to long double Daniel Rudy C Programming 5 09-20-2005 02:37 AM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
float, double, long double JKop C++ 4 08-08-2004 07:12 PM
Cast from (long double*) to (const double*) ferran C++ 9 04-12-2004 05:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57