- Introduction
- Class Overview
- Constructor
- Assignment Operators
- Arithmetic Operators
- Relational Operators
- IO Operators
- Getter Methods
- Example Usage
The BigReal
class is designed to represent real numbers with both integer and fractional components. It can handle large numbers that exceed the limitations of standard C++ data types by utilizing the BigDecimalInt
class for managing integer digits.
The class has the following private members:
BigDecimalInt integerDigits
: Represents the integer part of the real number.BigDecimalInt fractionDigits
: Represents the fractional part of the real number.char Sign
: Represents the sign of the real number ('+', '-' ).
It also provides various member functions for performing arithmetic operations, handling carries and borrows, and managing the format of fractions.
The BigReal
class provides several constructors:
BigReal(double = 0.0)
: Default constructor.BigReal(string)
: Constructor to initialize from a string.BigReal(BigDecimalInt)
: Constructor to initialize from aBigDecimalInt
object.BigReal(BigDecimalInt, BigDecimalInt, char)
: Constructor to initialize all components explicitly.
The class supports assignment from various types, including string
, BigDecimalInt
, int
, and long long
.
The class supports addition and subtraction operations for BigReal
objects.
Relational operators such as <
, >
, and ==
are implemented to compare BigReal
objects.
Input and output stream operators (<<
and >>
) are overloaded to facilitate easy input and output of BigReal
objects.
The class provides methods to retrieve the size and sign of the BigReal
object.
Here is an example of how to use the BigReal
class:
#include "BigReal.h"
#include <iostream>
// Your code goes here