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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started