• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

C: String arithmetic without Bignum library

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write a program (without using GMP library - https://gmplib.org) which performs arithmetic operations on large positive integers (addition, subtraction, multiplication and division).
Maximum number of digits in one number is 100.
Large number is the number that can't be represented by standard data types (long long, ...), and it is represented as a string.
Then allow incrementing and decrementing of a string, and finding the smallest and the largest string in an array of n strings.

How would you do incrementing, decrementing and comparing Bignum strings?
Here is the addition:
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are doing is what I learnt at school when I was about 8 called long multiplication. Do it on paper and you will be able to see how it works. For comparison what about padding the numbers from the left with 0s, then counting left to right until you find a digit which is different?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic