-
Notifications
You must be signed in to change notification settings - Fork 24
B: Number
Havik2 edited this page Feb 24, 2018
·
5 revisions
The Number class identifies values as numbers, includes arithmetic operations for numbers, has comparison operators, and identifies what type of number is being used.
Holds value of T
for any number. Uses the enum class NumberType
to hold the value of INTEGER
, REAL
, or RATIONAL
. type_tag
is used to label T
.
Has the arithmetic operations used for integer, rational, and real numbers +, -, *, /, %, |
. The |, or operator, is used to produce an integer value from the /
, divide operator if T
is of type INTEGER
. Also has the comparison operations ==, >, <, >=, <=, !=
. The code also does not allow the user to set the value of T
.
#include <iostream>
#include "shaka_scheme/system/base/Integer.hpp"
#include "shaka_scheme/system/base/Real.hpp"
#include "shaka_scheme/system/base/Rational.hpp"
int main() {
std::cout<<"Number"<<std::endl;
shaka::Number n(45);
std::cout<<n.get()<<std::endl;
std::cout<<n.get_type()<<std::endl;
}