Begin splitting code into separate files.
This commit is contained in:
28
include/types.hpp
Normal file
28
include/types.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include <mpfr.h>
|
||||
#include <string>
|
||||
#include "config.hpp"
|
||||
|
||||
struct string {
|
||||
std::string value;
|
||||
string(std::string&& new_value) : value(std::move(new_value)) {}
|
||||
string(const std::string& new_value) : value(new_value) {}
|
||||
};
|
||||
|
||||
struct number {
|
||||
mpfr_t value;
|
||||
number(const char* new_value) {
|
||||
mpfr_init2(value, PRECISION);
|
||||
mpfr_set_str(value, new_value, 10, MPFR_RNDN);
|
||||
}
|
||||
number(mpfr_t&& new_value) {
|
||||
std::swap(value, new_value);
|
||||
}
|
||||
int to_int() {
|
||||
return mpfr_get_si(value, MPFR_RNDN);
|
||||
}
|
||||
~number() {
|
||||
mpfr_clear(value);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user