range of long double variables

L

Leslaw Bieniasz

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
 
J

jacob navia

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

Juha Nieminen

jacob navia said:
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?
 
J

jacob navia

Le 21/02/11 15:33, Juha Nieminen a écrit :
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...
 
G

Geoff

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top