double double data type

J

James Simpson

Hello,
I tried to declare a double double in my MFC app and I get the following
error:
error C2632: 'double' followed by 'double' is illegal
Now I believe that double double is a valid built-in C++ data type and it
also happens to be the highest precision/largest value built-in type. Why is
the VC++ compiler giving me this error? Is there something I need to do
differently?

Regards,

James Simpson
Straightway Technologies Inc.
 
J

Jeroen Mostert

James said:
Hello,
I tried to declare a double double in my MFC app and I get the following
error:
error C2632: 'double' followed by 'double' is illegal
Now I believe that double double is a valid built-in C++ data type

Well, it's not. You're thinking of "long double".
 
B

Ben Voigt [C++ MVP]

Jeroen Mostert said:
Well, it's not. You're thinking of "long double".

Yes, it is the same pattern that turns "long" into "long long", but it is
"long $1", not "$1 $1".
 
C

Carl Daniel [VC++ MVP]

Jeroen said:
Well, it's not. You're thinking of "long double".

Also be aware that under VC++, 'double' and 'long double' have the same
representation - they're both 8-byte floating point. If you're writing
portable code and want to use the most precise floating point type
available, long double is for you even if it makes no difference under VC++.

-cd
 
J

James Simpson

Aside from writing my own class to handle high precision numeric values, is
there something else I can use to get a high precision floating point? The
code isn't portable (it's an MFC app).

Regards,
James Simpson
Straightway Technologies Inc.
 
C

Carl Daniel [VC++ MVP]

James said:
Aside from writing my own class to handle high precision numeric
values, is there something else I can use to get a high precision
floating point? The code isn't portable (it's an MFC app).

Sure. You can use one of the many high precision math libraries that you'll
find out on the net with a little searching. Be aware that the performance
will be orders of magnitude worse than the built-in double type.

-cd
 

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

Top