New datatype which can have numbers upto 100 digits.

Posted by ckv on Stack Overflow See other posts from Stack Overflow or by ckv
Published on 2010-06-18T11:54:09Z Indexed on 2010/06/18 12:03 UTC
Read the original article Hit count: 94

Note: This was an interview question and may not have an actual use case currently

The question was to design a class that can store numbers which are very very large say each number can have 100 digits. This new class is a datatype like int.

What are the different types of constructors, overloads and other functions that you would write.

How can this be further extended to support really large floating point numbers.

How this can be given to others so that they can reuse the same component with their own additional functionality.

My answer consisted of 2 approaches 1. using array of integers to store every say 10 digits 2. using string itself to store the number and perform operations on individual numbers.

What would be the best approach?

© Stack Overflow or respective owner

Related posts about c++

Related posts about interview-questions