Read Me
!!! All these programs and documentations are published under
Gnu Lesser General Public License Version 3 !!!
Copyright (C) 2016 Cosh Cage. (cyycoish@hotmail.com)
________________________________________________________________________________
Galaxy integer library (GILIB)
is an open source big integer calculation library written in plain C.
It try to provided a library as more compatible as C can.
A whole GILIB library is divided for such files now (1st August 2016):
================================================================================
1.gilib_krnl.h 2.gilib_krnl.c 3.gilib_extmem.h 4.gilib_extmem.c
5.gilib_multhd.h 6.gilib_multhd.c 7.gilib_math.h 8.gilib_math.c
9.gilib_interface.h 10.gilib_interface.cxx 11.gilib_logo.bmp 12.README
================================================================================
gilib_krnl header stored the critical declarations of GILIB integer structures
and basic functions like addition, subtraction, multiplication and division.
Some necessary macros are also written in this file.
As for the gilib_krnl C file, it achieve all the functions which declare in
gilib_krnl header file.
In these two files, there are several comments to indicate you how you can use
these functions. And there are also some demonstrations in accessories pack. What
you see is what you get. However how to use these functions correctly and more
efficiently is exactly a very important technic.
There is an Easter egg hidden in the variable magic_data in file gilib_extmem.c.
And the other part of this file achieve functions that makes you stored a Gint
number onto a disk. And it has a header file named gilib_extmem.h as well.
gilib_multhd.c Through this file we can use os's multithreading abilities to
accelerate our computing speed. Especially when we are attempting execute
tremendous arithmetic operations.
A small trick can help you replace normal gimul with multithreaded gimul. To
comment or uncomment preprocessor command #include "gilib_multhd.h" you can use
multiplication functions more flexible.
And I wrote a small number theory functions library for GILIB too. though it
has only 7 functions.
gilib_interface.h is a C Plus Plus header file stored some classes. These
classes packaged most of GILIB's kernel functions. And all the member functions
in these classes were achieved in gilib_interface.c.
The last one gilib_logo.bmp. It's just a pice of boring picture painted by
mspaint. I hope that someone can find our position in this image. Just for joke.
Here are some advices for you to fully use GILIB and to well extend it:
There is a writing form of all GILIB's functions. Just like assembly language,
kernel functions like giadd, gisub... add parameter a and b together and finally
stored the result in to a's address. In assembly language an add operation will
be written as: ADD AX, BX; In GILIB an add function is giadd(a, b); The target
memory address for the answer is always at the left side of one function's
parameter list. In mostly situation the parameter which on the right side of the
list will never be changed. But there is an exception: function bcdtogi in
gilib_krnl.c will clean parameter v's data after invoking.
In gilib_krnl you must remember that principle: Clean your new allocated memory
blocks before you use them. But you can drop it without any operations. That means
you must set new allocated Gint into zero. And remember, function gimov only copied
original Gint numbers data and it's flag. It don't check target's memory space. You
shall balance memory spaces by yourself.
Compiling Suggestions:
gilib_interface.h and gilib_interface.cxx these two are C Plus Plus files. Other
files are C files. They can compile with a C compiler.
If you are using an IDE. Things become easier. For example: in Visual Studio you
just put them all into your project and build it. But before that you must treat
these macros bellow carefully. So before you compile GILIB, I recommend you to
finish the following small checklist.
However it can reduce bugs as much as possible:
_________________________________________________________________
| # BEFORE COMPILING CHECK LIST # |\
| _ [ITEM] [TYPE] [FILE] [LINES] [MARK] |\
| [_] LOCALREG MACRO GILIB_KRNL.H 16 CONFIRM |\
| [_] _VC6_ MACRO GILIB_KRNL.H 20 CONFIRM |\
| [_] DATA_INITIAL_CAPACITY MACRO GILIB_KRNL.H 27 ALTER |\
| [_] TMP_DIR MACRO GILIB_EXTMEM.H 15 IMPORTANT |\
| [_] MAX_THREADS MACRO GILIB_MULTHD.H 14 ALTER |\
| [_] SIZE_MIN_CALC_UINT MACRO GILIB_MULTHD.H 15 ALTER |\
| [_] _OS_SWITCH_ MACRO GILIB_MULTHD.H 26 ALTER |\
| [_] _INLINE_ MACRO GILIB_MATH.H 15 CONFIRM |\
|_________________________________________________________________|\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
And then if you want to compile GILIB into a DLL, you can compiled it into a DLL.
If you wanna insert into your project, you just insert it. You can compile GILIB
onto an x86 platform. If you want to compile and run it on a x64 platform. It's
oKay. Never mind to do more modifications. Because I did it, numerous compatible
testing when I wrote this library.
I wish you can use GILIB and fall in love with it.
Cosh Cage August 1st 2016. In Matrix.