add 2 largest possible double numbers

This is a discussion on add 2 largest possible double numbers within the C Programming forums, part of the General Programming Boards category; hi, lets suppose, i declare the following long double a,b,c; a=1.1 E 4932; // this is the max possible range ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1

    Question add 2 largest possible double numbers

    hi,

    lets suppose, i declare the following

    long double a,b,c;

    a=1.1 E 4932; // this is the max possible range for long double
    b=1.1 E 4932; // this is the max possible range for long double

    c=a+b; // here there would be an overflow

    now how do i add a and b is my question and display their result. hope i could make myself clear. thanks.

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    I dont believe this is possible using the data types you are using. Look in yoru compilers documentation on 64bit floating point values. I think some compilers allow you to do long double or double double.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    Registered User tidda's Avatar
    Join Date
    Mar 2002
    Posts
    37

    I had done a similar problem a few weeks ago. There are two solutions.

    1) read all the data to a file and then read from the file and do the processing.

    2) dynamically increase the size of the memory in which u r storing the numbers. (Read the numbers as char)
    -tidda

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    There are some other threads on doing calculation with huge numbers or numbers with very high precision on this board. I suggest you do a search first and take a look at those threads.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion From C++ To C
    By dicon in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 03:54 PM
  2. expected primary expression
    By mju4t in forum C Programming
    Replies: 2
    Last Post: 03-27-2007, 07:59 PM
  3. Adding double numbers in a function
    By ybala in forum C Programming
    Replies: 1
    Last Post: 01-29-2003, 09:36 AM
  4. random double numbers
    By Gugge in forum C Programming
    Replies: 7
    Last Post: 05-18-2002, 12:26 AM
  5. Problem Formatting double numbers.
    By chaps67 in forum C++ Programming
    Replies: 1
    Last Post: 09-19-2001, 10:20 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21