adding huge doubles

Discussion in 'C++' started by dave, Sep 14, 2005.

  1. dave

    dave Guest

    I'm trying to learn this. My problem, I have 2 strings that represent
    floats.
    I want to add them together.
    Should I look at using Cint to convert each character in the string and add
    individually?
    or would grouping the "digits" in the string by say 10 or 20 and working the
    smaller parts?
    Would i loose something by grouping in that way?
    Or is there a faster/better way?
    I have been thinking about this for a while and I don't want to start the
    design off wrong.


    I can't convert them to floats because I need to keep the precision.
    I need to keep it c++ cause I don't remember assembler.

    thanks
    dave
    dave, Sep 14, 2005
    #1
    1. Advertising

  2. dave wrote:
    > I'm trying to learn this. My problem, I have 2 strings that represent
    > floats.
    > I want to add them together.
    > Should I look at using Cint to convert each character in the string
    > and add individually?
    > or would grouping the "digits" in the string by say 10 or 20 and
    > working the smaller parts?
    > Would i loose something by grouping in that way?
    > Or is there a faster/better way?
    > I have been thinking about this for a while and I don't want to start
    > the design off wrong.
    >
    >
    > I can't convert them to floats because I need to keep the precision.
    > I need to keep it c++ cause I don't remember assembler.


    Just look for "arbitrary precision floating point" or "bigint" or
    something like that, on the Web.

    V
    Victor Bazarov, Sep 14, 2005
    #2
    1. Advertising

  3. On Tue, 13 Sep 2005 22:18:33 -0400, "dave" <> wrote:

    >I'm trying to learn this. My problem, I have 2 strings that represent
    >floats.
    >I want to add them together.
    >Should I look at using Cint to convert each character in the string and add
    >individually?
    >or would grouping the "digits" in the string by say 10 or 20 and working the
    >smaller parts?
    >Would i loose something by grouping in that way?
    >Or is there a faster/better way?
    >I have been thinking about this for a while and I don't want to start the
    >design off wrong.
    >
    >
    >I can't convert them to floats because I need to keep the precision.
    >I need to keep it c++ cause I don't remember assembler.



    What's Cint?

    Will a double have enough precision?

    You can search for an arbitrary precision floating-point library to use, or
    use a vector to hold the digits, and iterate through them, adding digits a
    pair at a time.
    Dave Rahardja, Sep 14, 2005
    #3
  4. dave

    Greg Guest

    dave wrote:
    > I'm trying to learn this. My problem, I have 2 strings that represent
    > floats.
    > I want to add them together.
    > Should I look at using Cint to convert each character in the string and add
    > individually?
    > or would grouping the "digits" in the string by say 10 or 20 and working the
    > smaller parts?
    > Would i loose something by grouping in that way?
    > Or is there a faster/better way?
    > I have been thinking about this for a while and I don't want to start the
    > design off wrong.
    >
    >
    > I can't convert them to floats because I need to keep the precision.
    > I need to keep it c++ cause I don't remember assembler.
    >
    > thanks
    > dave


    How many digits of precision are needed for the floating point values?
    Simply adding the numbers will not require any additional precision.

    Assuming that the C/C++ compiler supports long doubles, it may be
    possible to represent as many as 18 digits of precision in a floating
    point variable.

    Greg
    Greg, Sep 14, 2005
    #4
    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. Kloofy
    Replies:
    0
    Views:
    316
    Kloofy
    Jul 8, 2005
  2. Rick
    Replies:
    3
    Views:
    1,053
    Chris Smith
    Oct 8, 2003
  3. Loek Raemakers

    Apache-Jserv: Servlet doubles info

    Loek Raemakers, Oct 21, 2004, in forum: Java
    Replies:
    0
    Views:
    308
    Loek Raemakers
    Oct 21, 2004
  4. dan
    Replies:
    1
    Views:
    2,302
    Jack Klein
    Nov 26, 2003
  5. Replies:
    3
    Views:
    479
Loading...

Share This Page