HRCore V1.1.0
A High Resolution Calculation Library
Loading...
Searching...
No Matches
Introdution & Guides

Welcome to the document of HRCore :-)

HRCore is a rough implement of high resolution calculation library, as a part of my C++ course big homework at the first term of SCUT.

It has implemented integer and float datatype, along with + - * / % operation, with two types of implement of storage structure.

Features

  • Almost unlimited data length
  • High resolution, with integers and floats
  • Limited calculation operator provided
  • Expression calculation supported
  • Support for std::cin & std::cout

About the structure

Just shown below:

dot_inline_dotgraph_1.png
General Structure

How to build

This library is header only and actually not need to build specially. Just include the file "HRCore.h" and compile, and that's it!

If you'd like to make a standalone header file, please your setup meet the following requirements:
Toolchain requirements:

  • GNU C Compiler that supports for C++11 standard (With C++0x may be OK)
  • CMake
  • GNU Make

Then, run cmake to configure the build and execute "make merge" in the build directory you have just specified.

Actually, the library is cross-platform and MSVC is also supported.

Examples

Example 01: The usage of Integer / Float

1
10// Define it in compiler argument(s) to use preconfigured and merged header file
11
12#ifdef HRCORE_USE_MERGE
13#include "../HRCore.hpp"
14#else
15#include "../HRCore.h"
16#endif
17
18using namespace std;
19using namespace HRCore;
20
21// Main function
22int main()
23{
24
25 int N = 0;
26 cin >> N;
27 while (N) {
28 char o = '+';
29 cin >> o;
30 // BINT a = BINT::make<Storage::LinkedList<8>>();
31 // BINT b = a.make();
32 BFLOAT a = BINT::make<Storage::LinkedList<8>>(); // using BINT::make() to get storage then convert to BFloat
33 BFLOAT b = a.make();
34 cin >> a >> b;
35 auto x = (o == '-' ? a - b : a + b);
36 cout << x << endl;
37 --N;
38 }
39 return 0;
40}
Float type.
Definition: Value.hpp:648
static Integer make()
Construct a new Integer object using given type of Storage::Interface implement.
Definition: Value.hpp:109
HRCore main namespace, contains all classes.
Definition: LinkedList.hpp:14

Example 02 The usage of Float::precision()

1
10// Define it in compiler argument(s) to use pre-configured and merged header file
11// #define HRCORE_USE_MERGE
12#ifdef HRCORE_USE_MERGE
13#include "../HRCore.hpp"
14#else
15#include "../HRCore.h"
16#endif
17
18using namespace std;
19using namespace HRCore;
20
21// Main function
22int main()
23{
24 BFLOAT d = BFLOAT::make<Storage::LinkedList<8>>();
25 d = 0.000001;
26 int N = 0;
27 cin >> N;
28 while (N) {
29 char o = '*';
30 cin >> o;
31
32 BFLOAT a = BINT::make<Storage::LinkedList<8>>();
33 BFLOAT b = a.make();
34
35 a.precision(10);
36 b.precision(10);
37 cin >> a >> b;
38 BFLOAT x = a.make();
39 if (o == '/') {
40 if (Utils::abs(b) < d) {
41 cout << "ERROR" << endl;
42 --N;
43 continue;
44 }
45 x = a / b;
46 } else {
47 x = a * b;
48 }
49 cout << x << endl;
50 --N;
51 }
52 return 0;
53}
size_t precision()
Get current precision of division and input.
Definition: Value.hpp:731