compiles!
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
/bin
|
||||||
|
/out
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
"folders": [
|
"folders": [
|
||||||
{
|
{
|
||||||
"path": "."
|
"path": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "../ckittylib"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
bin/bigmath/chain/operations.o: src/bigmath/chain/operations.cpp \
|
|
||||||
src/bigmath/chain/operations.hpp
|
|
||||||
src/bigmath/chain/operations.cpp:
|
|
||||||
src/bigmath/chain/operations.hpp:
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,7 @@
|
|||||||
CC := g++
|
CC := g++
|
||||||
|
|
||||||
#The Target Binary Program
|
#The Target Binary Program
|
||||||
TARGET := test.exe
|
TARGET := out.exe
|
||||||
|
|
||||||
#The Directories, Source, Includes, Objects, Binary and Resources
|
#The Directories, Source, Includes, Objects, Binary and Resources
|
||||||
SRCDIR := src
|
SRCDIR := src
|
||||||
@@ -14,15 +14,24 @@ OBJEXT := o
|
|||||||
|
|
||||||
#Flags, Libraries and Includes
|
#Flags, Libraries and Includes
|
||||||
ROOT := ./
|
ROOT := ./
|
||||||
CFLAGS := -Wall -std=c++20 -DBIGMATH_DEBUG
|
CFLAGS := -std=c++20 -O2 \
|
||||||
LFLAGS := -Wall -std=c++20 -static
|
-Wall -Werror -Wextra \
|
||||||
|
-Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align \
|
||||||
|
-Wunused -Woverloaded-virtual -Wconversion \
|
||||||
|
-Wsign-conversion -Wnull-dereference -Wdouble-promotion \
|
||||||
|
-Wformat=2 -Wimplicit-fallthrough -Wsuggest-override \
|
||||||
|
-Wextra-semi -Wduplicated-cond -Wduplicated-branches \
|
||||||
|
-Wlogical-op -Wuseless-cast -Wno-unused-parameter
|
||||||
|
LFLAGS := -std=c++20 -static-libstdc++ -static-libgcc \
|
||||||
|
-Wl,--fatal-warnings -Wl,--warn-common
|
||||||
|
LIBDIRS :=
|
||||||
LIB :=
|
LIB :=
|
||||||
INC := -I./src/ -I"$(ROOT)/../ckittylib/src"
|
INC := -I./src/ -I./../ckittylib/src/
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# DO NOT EDIT BELOW THIS LINE
|
# DO NOT EDIT BELOW THIS LINE
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
SOURCES := $(shell /c/msys64/usr/bin/find $(SRCDIR) -type f -name *.$(SRCEXT))
|
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
|
||||||
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
|
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
|
||||||
|
|
||||||
#Defauilt Make
|
#Defauilt Make
|
||||||
@@ -49,7 +58,7 @@ cleaner: clean
|
|||||||
|
|
||||||
#Link
|
#Link
|
||||||
$(TARGET): $(OBJECTS)
|
$(TARGET): $(OBJECTS)
|
||||||
$(CC) $(LFLAGS) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
|
$(CC) $(LFLAGS) -o $(TARGETDIR)/$(TARGET) $^ $(LIBDIRS) $(LIB)
|
||||||
|
|
||||||
#Compile
|
#Compile
|
||||||
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
|
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
|
||||||
|
|||||||
Binary file not shown.
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <bigmath/BigMath.hpp>
|
#include <bigmath/BigMath.hpp>
|
||||||
#include <bigmath/chain/segment.hpp>
|
#include <bigmath/chain/segment.hpp>
|
||||||
//#include <bigmath/chain/operations.hpp>
|
|
||||||
|
|
||||||
#include <ckitty/memory/buffers.hpp>
|
#include <ckitty/memory/buffers.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -4,23 +4,6 @@
|
|||||||
#include <ckitty/memory/array.hpp>
|
#include <ckitty/memory/array.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef BIGMATH_DEBUG
|
|
||||||
|
|
||||||
#define BIGMATH_ASSERT(EXPR, ERR_MSG) \
|
|
||||||
if(!(EXPR)) throw std::runtime_error(ERR_MSG)
|
|
||||||
|
|
||||||
#define BIGMATH_DLOG(MSG) \
|
|
||||||
std::cerr << MSG << std::endl
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define BIGMATH_ASSERT(EXPR, ERR_MSG) do {} while(0)
|
|
||||||
|
|
||||||
#define BIGMATH_DLOG(MSG) do {} while(0)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace bigmath {
|
namespace bigmath {
|
||||||
|
|
||||||
using namespace ckitty;
|
using namespace ckitty;
|
||||||
@@ -28,8 +11,4 @@ namespace bigmath {
|
|||||||
class segment;
|
class segment;
|
||||||
class chain;
|
class chain;
|
||||||
|
|
||||||
using d10_t = u8;
|
|
||||||
using digits_t = d10_t*;
|
|
||||||
using dlen_t = u8;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,34 +5,30 @@
|
|||||||
|
|
||||||
namespace bigmath {
|
namespace bigmath {
|
||||||
|
|
||||||
const dlen_t segment::digit_count = 128;
|
const u8 segment::digit_count = 128;
|
||||||
const dlen_t segment::byte_count = segment::digit_count / 2;
|
const u8 segment::byte_count = segment::digit_count / 2;
|
||||||
|
|
||||||
segment::segment() {
|
segment::segment() : digits{} {}
|
||||||
digits = new dlen_t[byte_count]{};
|
|
||||||
}
|
|
||||||
|
|
||||||
segment::~segment() {
|
segment::~segment() {}
|
||||||
delete[] digits;
|
|
||||||
}
|
|
||||||
|
|
||||||
d10_t segment::operator[](dlen_t i) const {
|
u8 segment::operator[](u8 i) const {
|
||||||
dlen_t j = i >> 1;
|
u8 j = i >> 1;
|
||||||
dlen_t k = (i & 1) * 4;
|
u8 k = (i & 1) * 4;
|
||||||
d10_t b = digits[j];
|
u8 b = digits[j];
|
||||||
return (b >> k) & 0xFu;
|
return (b >> k) & 0xFu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void segment::set(dlen_t i, d10_t n) {
|
void segment::set(u8 i, u8 n) {
|
||||||
dlen_t j = i >> 1;
|
u8 j = i >> 1;
|
||||||
dlen_t k = (i & 1) * 4;
|
u8 k = (i & 1) * 4;
|
||||||
d10_t b = digits[j];
|
u8 b = digits[j];
|
||||||
b &= 0xF0u >> k;
|
b &= 0xF0u >> k;
|
||||||
n &= 0xFu;
|
n &= 0xFu;
|
||||||
digits[j] = b | (n << k);
|
digits[j] = b | (n << k);
|
||||||
}
|
}
|
||||||
|
|
||||||
const digits_t segment::bytes() const {
|
const u8* segment::bytes() const {
|
||||||
return digits;
|
return digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,14 +36,14 @@ namespace bigmath {
|
|||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
||||||
// We'll iterate backwards
|
// We'll iterate backwards
|
||||||
size_t i = digit_count;
|
isize i = digit_count;
|
||||||
u32 use_space = 0;
|
u32 use_space = 0;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
d10_t val = operator[](i - 1);
|
u8 val = operator[](u8(i - 1));
|
||||||
|
|
||||||
// Count repetitions
|
// Count repetitions
|
||||||
size_t count = 1;
|
isize count = 1;
|
||||||
while (i > count && operator[](i - count - 1) == val) ++count;
|
while (i > count && operator[](u8(i - count - 1)) == val) ++count;
|
||||||
|
|
||||||
// temporal string
|
// temporal string
|
||||||
std::ostringstream one;
|
std::ostringstream one;
|
||||||
@@ -60,7 +56,7 @@ namespace bigmath {
|
|||||||
out << "[" << str << " x " << count << "]";
|
out << "[" << str << " x " << count << "]";
|
||||||
use_space = 4;
|
use_space = 4;
|
||||||
} else {
|
} else {
|
||||||
for (size_t j = 0; j < count; ++j) {
|
for (isize j = 0; j < count; ++j) {
|
||||||
if(use_space > 3) {
|
if(use_space > 3) {
|
||||||
out << " ";
|
out << " ";
|
||||||
use_space = 1;
|
use_space = 1;
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ namespace bigmath {
|
|||||||
class segment {
|
class segment {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const dlen_t digit_count;
|
static const u8 digit_count;
|
||||||
static const dlen_t byte_count;
|
static const u8 byte_count;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
digits_t digits;
|
u8 digits[128];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -25,13 +25,13 @@ namespace bigmath {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
d10_t operator[](dlen_t i) const;
|
u8 operator[](u8 i) const;
|
||||||
|
|
||||||
void set(dlen_t i, d10_t n);
|
void set(u8 i, u8 n);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const digits_t bytes() const;
|
const u8* bytes() const;
|
||||||
|
|
||||||
std::string describe() const;
|
std::string describe() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user