Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > precision in C++

Reply
Thread Tools

precision in C++

 
 
asdf
Guest
Posts: n/a
 
      08-04-2006
I want to set the computation precision to quadruple precision, how can
I do it in C++ coding?

Thanks all.

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-04-2006
asdf wrote:
> 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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      08-04-2006
"asdf" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
: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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com


 
Reply With Quote
 
asdf
Guest
Posts: n/a
 
      08-04-2006
"long double" corresponds to double precision, right?
I want to use quadruple precision instead.

Thanks.

Ivan Vecerina wrote:
> "asdf" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> :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
> --
> http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
> Brainbench MVP for C++ <> http://www.brainbench.com


 
Reply With Quote
 
Paulo Matos
Guest
Posts: n/a
 
      08-04-2006

asdf wrote:
> "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

 
Reply With Quote
 
Paulo Matos
Guest
Posts: n/a
 
      08-04-2006

Paulo Matos wrote:
> asdf wrote:
> > "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.
>


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

> Cheers,
>
> Paulo Matos


 
Reply With Quote
 
Geo
Guest
Posts: n/a
 
      08-04-2006

asdf wrote:
> "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

 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      08-04-2006
In article <(E-Mail Removed) .com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
>
> asdf wrote:
> > "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


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.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-04-2006
Jerry Coffin wrote:
> In article <(E-Mail Removed) .com>,
> (E-Mail Removed) says...
>>
>> asdf wrote:
>>> "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

>
> 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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      08-04-2006
asdf wrote:

> "long double" corresponds



See below.



Brian

--
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.htm>
 
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
ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value jwtulp@hotmail.com ASP .Net 0 01-01-2006 02:47 PM
ERROR: [ODBC Microsoft Access Driver]Invalid precision value =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 09-09-2005 01:26 PM
Bug in double precision computing? Daniel Geisenhoff ASP .Net 1 07-29-2004 01:58 PM
Need > 15 digits precision without big performance hit Jasper Perl 1 06-27-2004 08:25 AM
Decimal precision ? Piotr ASP .Net 1 04-02-2004 12:43 PM



Advertisments