diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5734f07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bin +/out diff --git a/bigmath.code-workspace b/bigmath.code-workspace index b0fd153..70eebc6 100644 --- a/bigmath.code-workspace +++ b/bigmath.code-workspace @@ -2,6 +2,9 @@ "folders": [ { "path": "." + }, + { + "path": "../ckittylib" } ], "settings": { diff --git a/bin/bigmath/BigMath.o b/bin/bigmath/BigMath.o index c280bf1..0590c7d 100644 Binary files a/bin/bigmath/BigMath.o and b/bin/bigmath/BigMath.o differ diff --git a/bin/bigmath/chain/chain.o b/bin/bigmath/chain/chain.o index f23eb76..50b4436 100644 Binary files a/bin/bigmath/chain/chain.o and b/bin/bigmath/chain/chain.o differ diff --git a/bin/bigmath/chain/operations.d b/bin/bigmath/chain/operations.d deleted file mode 100644 index 07a31cb..0000000 --- a/bin/bigmath/chain/operations.d +++ /dev/null @@ -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: diff --git a/bin/bigmath/chain/operations.o b/bin/bigmath/chain/operations.o deleted file mode 100644 index 67ed80f..0000000 Binary files a/bin/bigmath/chain/operations.o and /dev/null differ diff --git a/bin/bigmath/chain/segment.o b/bin/bigmath/chain/segment.o index 3ee832e..ed5821b 100644 Binary files a/bin/bigmath/chain/segment.o and b/bin/bigmath/chain/segment.o differ diff --git a/bin/bigmath/chain/util.o b/bin/bigmath/chain/util.o index c5752b7..393244e 100644 Binary files a/bin/bigmath/chain/util.o and b/bin/bigmath/chain/util.o differ diff --git a/makefile b/makefile index 766ebda..c392ee5 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ CC := g++ #The Target Binary Program -TARGET := test.exe +TARGET := out.exe #The Directories, Source, Includes, Objects, Binary and Resources SRCDIR := src @@ -14,15 +14,24 @@ OBJEXT := o #Flags, Libraries and Includes ROOT := ./ -CFLAGS := -Wall -std=c++20 -DBIGMATH_DEBUG -LFLAGS := -Wall -std=c++20 -static +CFLAGS := -std=c++20 -O2 \ + -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 := -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))) #Defauilt Make @@ -49,7 +58,7 @@ cleaner: clean #Link $(TARGET): $(OBJECTS) - $(CC) $(LFLAGS) -o $(TARGETDIR)/$(TARGET) $^ $(LIB) + $(CC) $(LFLAGS) -o $(TARGETDIR)/$(TARGET) $^ $(LIBDIRS) $(LIB) #Compile $(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) @@ -62,4 +71,4 @@ $(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) @rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp #Non-File Targets -.PHONY: all remake clean cleaner resources \ No newline at end of file +.PHONY: all remake clean cleaner resources diff --git a/out/test.exe b/out/test.exe deleted file mode 100644 index 2721c35..0000000 Binary files a/out/test.exe and /dev/null differ diff --git a/src/bigmath/BigMath.cpp b/src/bigmath/BigMath.cpp index 863e242..b926b4f 100644 --- a/src/bigmath/BigMath.cpp +++ b/src/bigmath/BigMath.cpp @@ -2,7 +2,6 @@ #include #include -//#include #include diff --git a/src/bigmath/BigMath.hpp b/src/bigmath/BigMath.hpp index 8540aae..50d3f57 100644 --- a/src/bigmath/BigMath.hpp +++ b/src/bigmath/BigMath.hpp @@ -4,23 +4,6 @@ #include #include -#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 { using namespace ckitty; @@ -28,8 +11,4 @@ namespace bigmath { class segment; class chain; - using d10_t = u8; - using digits_t = d10_t*; - using dlen_t = u8; - } diff --git a/src/bigmath/chain/segment.cpp b/src/bigmath/chain/segment.cpp index a489873..e0b8b13 100644 --- a/src/bigmath/chain/segment.cpp +++ b/src/bigmath/chain/segment.cpp @@ -5,34 +5,30 @@ namespace bigmath { - const dlen_t segment::digit_count = 128; - const dlen_t segment::byte_count = segment::digit_count / 2; + const u8 segment::digit_count = 128; + const u8 segment::byte_count = segment::digit_count / 2; - segment::segment() { - digits = new dlen_t[byte_count]{}; - } + segment::segment() : digits{} {} - segment::~segment() { - delete[] digits; - } + segment::~segment() {} - d10_t segment::operator[](dlen_t i) const { - dlen_t j = i >> 1; - dlen_t k = (i & 1) * 4; - d10_t b = digits[j]; + u8 segment::operator[](u8 i) const { + u8 j = i >> 1; + u8 k = (i & 1) * 4; + u8 b = digits[j]; return (b >> k) & 0xFu; } - void segment::set(dlen_t i, d10_t n) { - dlen_t j = i >> 1; - dlen_t k = (i & 1) * 4; - d10_t b = digits[j]; + void segment::set(u8 i, u8 n) { + u8 j = i >> 1; + u8 k = (i & 1) * 4; + u8 b = digits[j]; b &= 0xF0u >> k; n &= 0xFu; digits[j] = b | (n << k); } - const digits_t segment::bytes() const { + const u8* segment::bytes() const { return digits; } @@ -40,14 +36,14 @@ namespace bigmath { std::ostringstream out; // We'll iterate backwards - size_t i = digit_count; + isize i = digit_count; u32 use_space = 0; while (i > 0) { - d10_t val = operator[](i - 1); + u8 val = operator[](u8(i - 1)); // Count repetitions - size_t count = 1; - while (i > count && operator[](i - count - 1) == val) ++count; + isize count = 1; + while (i > count && operator[](u8(i - count - 1)) == val) ++count; // temporal string std::ostringstream one; @@ -60,7 +56,7 @@ namespace bigmath { out << "[" << str << " x " << count << "]"; use_space = 4; } else { - for (size_t j = 0; j < count; ++j) { + for (isize j = 0; j < count; ++j) { if(use_space > 3) { out << " "; use_space = 1; diff --git a/src/bigmath/chain/segment.hpp b/src/bigmath/chain/segment.hpp index 48f1b2a..13d7cd4 100644 --- a/src/bigmath/chain/segment.hpp +++ b/src/bigmath/chain/segment.hpp @@ -10,12 +10,12 @@ namespace bigmath { class segment { public: - static const dlen_t digit_count; - static const dlen_t byte_count; + static const u8 digit_count; + static const u8 byte_count; private: - digits_t digits; + u8 digits[128]; public: @@ -25,13 +25,13 @@ namespace bigmath { 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: - const digits_t bytes() const; + const u8* bytes() const; std::string describe() const;