precision in C++

Discussion in 'C++' started by asdf, Aug 4, 2006.

  1. asdf

    asdf Guest

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

    Thanks all.
    asdf, Aug 4, 2006
    #1
    1. Advertising

  2. 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
    Victor Bazarov, Aug 4, 2006
    #2
    1. Advertising

  3. "asdf" <> wrote in message
    news:...
    :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
    Ivan Vecerina, Aug 4, 2006
    #3
  4. asdf

    asdf Guest

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

    Thanks.

    Ivan Vecerina wrote:
    > "asdf" <> wrote in message
    > news:...
    > :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
    asdf, Aug 4, 2006
    #4
  5. asdf

    Paulo Matos Guest

    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
    Paulo Matos, Aug 4, 2006
    #5
  6. asdf

    Paulo Matos Guest

    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
    Paulo Matos, Aug 4, 2006
    #6
  7. asdf

    Geo Guest

    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
    Geo, Aug 4, 2006
    #7
  8. asdf

    Jerry Coffin Guest

    In article <>,
    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.
    Jerry Coffin, Aug 4, 2006
    #8
  9. Jerry Coffin wrote:
    > In article <>,
    > 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
    Victor Bazarov, Aug 4, 2006
    #9
  10. asdf

    Default User Guest

    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>
    Default User, Aug 4, 2006
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jasper
    Replies:
    1
    Views:
    443
    Joe Smith
    Jun 27, 2004
  2. Piotr

    Decimal precision ?

    Piotr, Apr 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,562
    Martin Dechev
    Apr 2, 2004
  3. Daniel Geisenhoff

    Bug in double precision computing?

    Daniel Geisenhoff, Jul 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    324
    Shan Plourde
    Jul 29, 2004
  4. =?Utf-8?B?UmV6YSBOYWJp?=

    ERROR: [ODBC Microsoft Access Driver]Invalid precision value

    =?Utf-8?B?UmV6YSBOYWJp?=, Sep 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,621
    Paul Clement
    Sep 9, 2005
  5. Replies:
    0
    Views:
    3,557
Loading...

Share This Page