Question: Write a C++ implementation for defining signed integers with a maximum size of 100. Use this interface, BigNum.h. Check for underflow and overflow. #ifndef _BIG_NUM_H

Write a C++ implementation for defining signed integers with a maximum size of 100. Use this interface, BigNum.h. Check for underflow and overflow.

#ifndef _BIG_NUM_H #define _BIG_NUM_H namespace PROGM {

class BigNum { public: static const int MAX_VALUES = 100; enum class Signed {POSITIVE, NEGATIVE,ZERO};

BigNum (); //initialize to 0 BigNum(long long a); //exits if too large BigNum(std::string b); //exits if too large int getLen() const;

int cmp(BigNum& op2) const; //returns -1 if less, 0 if equal, or 1 if greater

BigNum abs() const; //does absolute value BigNum sum(BigNum& op2) const; BigNum difference(BigNum& op2) const; BigNum multiplication(BigNum& op2) const; BigNum division(BigNum& op2) const; BigNum remainder(BigNum& op2) const;

friend std::ostream& operator <<(std::ostream& os, const BigNum& a);

private: int values[MAX_VALUES]; Signed signed; int length; // length of number not including sign

}; } #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!