precision in C++

A

asdf

I want to set the computation precision to quadruple precision, how can
I do it in C++ coding?

Thanks all.
 
V

Victor Bazarov

asdf said:
I want to set the computation precision to quadruple precision, how
can I do it in C++ coding?

You can't, unless your compiler somehow enables that. However, there
are libraries out there implementing arbitrary (or simply extended)
precision floating point calculations. Just look for them on the Web.
They may be slower than possible hardware-provided one, but on many
processors it's the only thing available.

V
 
I

Ivan Vecerina

:I want to set the computation precision to quadruple precision, how can
: I do it in C++ coding?

Its implementation details depend on the platform, but
would the bult-in type "long double" meet your needs ?

hth -Ivan
 
A

asdf

"long double" corresponds to double precision, right?
I want to use quadruple precision instead.

Thanks.
 
P

Paulo Matos

asdf said:
"long double" corresponds to double precision, right?
I want to use quadruple precision instead.

Thanks.

You're asking for too much then. Check GMP mpf_t.

Cheers,

Paulo Matos
 
P

Paulo Matos

Paulo said:
You're asking for too much then. Check GMP mpf_t.

Let me add GMP as a C++ interface, the type mpf_t corresponds to the
class mpf_class (I think)!
 
G

Geo

asdf said:
"long double" corresponds to double precision, right?
I want to use quadruple precision instead.

No I wouldn't think so,

float - sinlge precision
double - double precision (surprisingly!!!)
long double - greater than double precision
 
J

Jerry Coffin

No I wouldn't think so,

float - sinlge precision
double - double precision (surprisingly!!!)
long double - greater than double precision

Not really. More accurately, long double is "greater than or equal to
double precision" -- there's no requirement that its precision is
actually greater, and on some widely used implementations (e.g. VC++
2.0 and above) the precision of double and long double is the same.
 
V

Victor Bazarov

Jerry said:
Not really. More accurately, long double is "greater than or equal to
double precision" -- there's no requirement that its precision is
actually greater, and on some widely used implementations (e.g. VC++
2.0 and above) the precision of double and long double is the same.

....and on some implementations it's not *much* greater. For example, IIRC,
Borland made use of 'long double' in 10-byte representation, which only
gives you 19 digits of precision (mere 3 more than 'double'), although it
does have a greater range. See "extended double" IEEE 754 format (IIRC).

V
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top