compiles!

This commit is contained in:
2026-07-30 08:45:51 -06:00
parent 2132185afb
commit 5b7b205f37
14 changed files with 46 additions and 62 deletions
+2
View File
@@ -0,0 +1,2 @@
/bin
/out
+3
View File
@@ -2,6 +2,9 @@
"folders": [
{
"path": "."
},
{
"path": "../ckittylib"
}
],
"settings": {
Binary file not shown.
Binary file not shown.
-4
View File
@@ -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.
+15 -6
View File
@@ -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
#---------------------------------------------------------------------------------
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)
BIN
View File
Binary file not shown.
-1
View File
@@ -2,7 +2,6 @@
#include <bigmath/BigMath.hpp>
#include <bigmath/chain/segment.hpp>
//#include <bigmath/chain/operations.hpp>
#include <ckitty/memory/buffers.hpp>
-21
View File
@@ -4,23 +4,6 @@
#include <ckitty/memory/array.hpp>
#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 {
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;
}
+18 -22
View File
@@ -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;
+6 -6
View File
@@ -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;