Thread: Adding Long Integers!

  1. #1
    Registered User alireza beygi's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    17

    Adding Long Integers!

    How can we add too long integers (for example 20 digits) with usage of Strings?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I like to use four char arrays:
    carry[]
    add1[]
    add2[]
    =====
    sum[]

    Set each of them up with an initial value of 0 in them, and use them just like you would do it by hand, with a pencil, working from right to left. (so your index decrements, not increments).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. long integers and byte order
    By sonnichs in forum C Programming
    Replies: 19
    Last Post: 08-12-2011, 01:01 PM
  2. Long integers not long enough
    By cnewbie1 in forum C Programming
    Replies: 14
    Last Post: 10-31-2010, 04:32 AM
  3. Long Integers
    By SimonM in forum C Programming
    Replies: 25
    Last Post: 07-25-2007, 01:57 PM
  4. Long Integers
    By kabuatama in forum C Programming
    Replies: 24
    Last Post: 01-28-2006, 01:21 PM
  5. C++ help!!!!! Adding integers
    By PR1MO in forum C++ Programming
    Replies: 3
    Last Post: 04-30-2003, 05:40 PM