Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   range of long double variables (http://www.velocityreviews.com/forums/t743924-range-of-long-double-variables.html)

Leslaw Bieniasz 02-21-2011 11:00 AM

range of long double variables
 


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

jacob navia 02-21-2011 01:23 PM

Re: range of long double variables
 
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.

Juha Nieminen 02-21-2011 02:33 PM

Re: range of long double variables
 
jacob navia <jacob@spamsink.net> 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?

jacob navia 02-21-2011 03:23 PM

Re: range of long double variables
 
Le 21/02/11 15:33, Juha Nieminen a écrit :
> jacob navia<jacob@spamsink.net> 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...


Geoff 02-21-2011 03:52 PM

Re: range of long double variables
 
On Mon, 21 Feb 2011 12:00:29 +0100, Leslaw Bieniasz
<nbbienia@cyf-kr.edu.pl> 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?


All times are GMT. The time now is 04:14 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.