-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
62 lines (57 loc) · 3.74 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "integer.hpp"
#include <iostream>
#include <string>
int main() {
// Constructors and output
std::cout << "Copy constructor: " << bnl::integer(bnl::integer("123456")) << std::endl;
std::cout << "From string constructor: " << bnl::integer("9999999999") << std::endl;
std::cout << " " << bnl::integer("12348.1155") << std::endl;
std::cout << " " << bnl::integer("-123456789") << std::endl;
std::cout << " " << bnl::integer("-987654.44") << std::endl;
std::cout << " " << bnl::integer("12348E11") << std::endl;
std::cout << " " << bnl::integer("1.2348E11") << std::endl;
std::cout << " " << bnl::integer("12348E-3") << std::endl;
std::cout << " " << bnl::integer("98765.12E-3") << std::endl;
std::cout << " " << bnl::integer(".12E2") << std::endl;
std::cout << " " << bnl::integer("-.15") << std::endl;
std::cout << " " << bnl::integer("345.") << std::endl;
std::cout << "From long double constructor: " << bnl::integer(98765.12E-3) << std::endl << std::endl;
// Common operators
bnl::integer a = "465978445001246";
bnl::integer b = "17803599121421";
std::cout << "Negation: " << -a << std::endl;
std::cout << "Not: " << !a << std::endl;
std::cout << "Not (bitwise): " << ~a << std::endl;
std::cout << "Adition: " << a + b << std::endl;
std::cout << "Subtraction: " << a - b << std::endl;
std::cout << "Multiplication: " << a * b << std::endl;
std::cout << " " << a * -b << std::endl;
std::cout << " " << -a * -b << std::endl;
std::cout << "Division: " << a / b << std::endl;
std::cout << " " << -a / b << std::endl;
std::cout << " " << b / a << std::endl;
std::cout << "Division: " << a / b << std::endl;
std::cout << "Left shift: " << (a << bnl::integer("24")) << std::endl;
std::cout << " " << (-a << bnl::integer("24")) << std::endl;
std::cout << "Right shift: " << (a >> bnl::integer("24")) << std::endl;
std::cout << " " << (-a >> bnl::integer("24")) << std::endl;
std::cout << "Greater than: " << (a > b) << std::endl;
std::cout << "Less than: " << (a < b) << std::endl;
std::cout << "Greater or equal than: " << (a >= b) << std::endl;
std::cout << "Less or equal than: " << (a <= b) << std::endl;
std::cout << "Equal to: " << (a == b) << std::endl;
std::cout << "Not equal to: " << (a != b) << std::endl;
std::cout << "AND (bitwise): " << (a & b) << std::endl;
std::cout << "OR (bitwise): " << (a | b) << std::endl;
std::cout << "XOR (bitwise): " << (a ^ b) << std::endl;
std::cout << "AND: " << (a && b) << std::endl;
std::cout << "OR: " << (a || b) << std::endl;
std::cout << "Try with others numbers, operator combination and assignations..." << std::endl << std::endl;
// Helpful functions
std::cout << "Absolute value: " << bnl::abs(a) << std::endl;
std::cout << " " << bnl::abs(-a) << std::endl;
std::cout << "Maximum: " << bnl::max(a, b) << std::endl;
std::cout << "Minimum: " << bnl::min(a, b) << std::endl;
std::cout << "Power: " << bnl::pow(a, bnl::integer("8")) << std::endl;
return 0;
}