Skip to content

julienlargetpiet/Cherubin

Repository files navigation

README

Table Of Contents


#Description

This library if for very large and precise number (integers or floating points) manipulation those who can not be stored in an other datatype than std::string or std::deque. The only limit is the system memory.





Addition

addabstraction

#Usage

std::string addabstraction(std::string x, std::string x2)

Returns the result of any addition between positive and/or negative values. Handles the abstraction for addflt function that normally does not accept negative value.

#Arguments

NameDefinition
x the first number (int or float as std string)
x2 the second number (int or float as std string)

#Example(s)


std::string x = "0.5";
std::string x2 = "2.5";
addabstraction(x, x2);
"3.0"
x2 = "-2.5";
addabstraction(x, x2);
"-2.0"


Integers

addint

#Usage

std::string addint(std::string &x, std::string &x2)

#Description

Returns the result as a std string.

#Arguments

NameDefinition
x is the first positive int as a string
x2 is the second positive int as a string

#Example(s)

std::string a = "4";
std::string b = "112";
addint(a, b);
"116"

x = "1458970";
x2 = "563489287";
addint(x, x2);
"564948257"


Floating points

addflt

#Usage

std::string addflt(std::string &x, std::string &x2)

#Description

Returns the addition of two floating points as a std string. Accepts integers, but if you plan to add integers, addint is preferable to use.

#Arguments

NameDefinition
x is one of the int or float that will be part of the addition operation
x2 is one of the int or float that will be part of the addition operation

#Example(s)


std::string x = "14589.70";
std::string x2 = "5634.89287";
adflt(x, x2);
"20224.59287"


addflt2

#Usage

std::string addflt(std::string x, std::string x2)

#Description

Same as addflt with another algorithm.

#Arguments

NameDefinition
x is one of the int or float that will be part of the addition operation
x2 is one of the int or float that will be part of the addition operation

#Example(s)


std::string x = "14589.70";
std::string x2 = "5634.89287";
adflt2(x, x2);
"20224.59287"


Substraction

subsabstraction

#Usage

std::string subsabstraction(std::string x, std::string x2)

#Description

Returns the result of a substraction. Handles the abstraction needed for subsflt function that normally does not accept negative inputs.

#Arguments

NameDefinition
x is the number that will be substracted (int or float as std string)
x2 is the number that will substract x

#Example(s)


std::string x = "-5687.58";
std::string x2 = "-459372";
subsabstraction(x2, x);
"-465059.58"


Integers

subsint

#Usage

std::string subsint(std::string &x, std::string &x2)

#Description

Returns the result as a std string.

#Arguments

NameDefinition
x is the first positive int as a string, must be greater or equal to to x2
x2 is the second positive int as a string, must be lower or equal to x

#Example(s)


std::string x = "1458970";
std::string x2 = "563489287";
subsint(x2, x);
"562030317"


Floating points

subsflt

#Usage

std::string subsflt(std::string &x, std::string &x2)

#Description

Returns the substraction of two floating point numbers. Accepts integers, but if you plan to substract integers, it is preferable to use subsint function.

#Arguments

NameDefinition
x is a number represented as a string, must be higher or equal to the second number
x2 is a number represented as a string, must be lower or equal to the second number

#Example(s)


std::string x = "14589.70";
std::string x2 = "56348.9287";
subsflt(x2, x) ;
"41759.2287"


Multiplication

multabstraction

#Usage

std::string multabstraction(std::string x, std::string x2)

#Description

Returns the result of a multiplication. Handles the abstraction for multflt2 that normaly does not accept negative values.

#Arguments

NameDefinition
x is the first number (int or float as std string)
x2 is the second number (int or float as std string)

#Example(s)


std::string x = "-569.87";
std::string x2 = "459372";
multabstraction(x, x2);
"-261782321.640"


Integers

multint

#Usage

std::string multint(std::string &x, unsigned int &x2)

#Description

Returns the multiplication of two integers as std string.

#Arguments

NameDefinition
x is an integer higher than 0 as a std string
x2 is an unsigned integer higher than 0

#Example(s)


std::string x = "1458970";
unsigned int x2b = 45;
multint(x, x2);
"65653650"


multint2

#Usage

std::string multint2(std::string &x, std::string &x2)

#Description

Returns the multiplication of two integers as std string.

#Arguments

NameDefinition
x is an integer higher tha 0 as a std string
x2 is an integer higher than 0 as a std string

#Example(s)


std::string x = "1458970";
std::string x2 = "563489287";
multint2(x, x2);
"822113965054390"


Floating points

multflt

#Usage

std::string multflt(std::string &x, std::string &x2)

#Description

Returns the result of a multpilication as a std string from floating points or integers as std string.

#Arguments

NameDefinition
x is a floating points or integer as a std string
x2 is a floating points or integer as a std string

#Example(s)


std::string x = "1458.970";
std::string x2 = "563489.287";
multflt(x, x2);
"822113965.054390"


multflt2

#Usage

std::string multflt2(std::string &x, std::string &x2)

#Description

Same as multflt, but with another algorithm.

#Arguments

NameDefinition
x is a floating points or integer as a std string
x2 is a floating points or integer as a std string

#Example(s)


std::string x = "1458.970";
std::string x2 = "563489.287";
multflt2(x, x2);
"822113965.05439000000"


multbase10

#Usage

std::string multbase10(std::string x, unsigned int base = 9)

#Arguments

NameDefinition
x is the int of float that will be multiplied, as a std string
base is the number of 0 of the base 10 multiplicator

#Example(s)


std::string x = "1458.970";
multbase10(x);
"1458970000000.0"


Division

divideabstraction

#Usage

std::string divideabstraction(std::string x, std::string x2, unsigned int nb_decimal = 5)

#Description

Returns the result of a division. Handles the abstraction for divide2 that normaly does not accept negative values.

#Arguments

NameDefinition
x is the first number (int or float as std string)
x2 is the second number (int or float as std string)
nb_decimal is the number of decimal to keep

#Example(s)


std::string x = "-569.87";
std::string x2 = "459372";
divideabstraction(x, x2);
"-0.001240541"


divide2

#Usage

std::string divide2(std::string &x, std::string &x2, unsigned int nb_decimal = 8)

#Description

Returns the result of a division between ints or floats represented as std string.

#Arguments

NameDefinition
x is a int or float that will be divided represented as a std string, must be superior or equal to 1, refer to centerizer() to center your division to make the divided equal to 1 or higher
x2 is a int or float that will divide represented as a std string
nb_decimal is an int representing the number of decimal to keep as a result

#Example(s)


std::string x = "1458.970";
std::string x2 = "563489.287";
divide2(x2, x);
"386.22400"


divide

#Usage

std::string divide(std::string &x, std::string &x2, unsigned int nb_decimal = 8)

#Description

!!Obsolete!! Returns the result of a division between ints or floats represented as std string.

#Arguments

NameDefinition
x is a int or float that will be divided represented as a std string, must be superior or equal to 1, refer to centerizer() to center your division to make the divided equal to 1 or higher
x2 is a int or float that will divide represented as a std string

#Example(s)


std::string x = "1458.970";
std::string x2 = "563489.287";
divide(x2, x);
"386.2240"


dividebase10

#Usage

std::string dividebase10(std::string &x, unsigned int accuracy = 9)

#Description

Returns the result of a division base 10.

#Arguments

NameDefinition
x is the int or float that will be divided, as a std string
base is the number of 0 of the base 10 multiplicator

#Example(s)


std::string x2 = "563489.287";
dividebase10(x2);
"0.000563489287"


dividebase10_2

#Usage

std::string dividebase10_2(std::string x, int divider = 9)

#Description

Returns the result of an int or float (as a std string) divided by a base 10 divider.

#Arguments

NameDefinition
x is the int of float that will be divided
divider is an int that indicates the number of zero of the base 10 divider

#Example(s)


std::string x2 = "563489.287";
dividebase10_2(x2);
"0.000563489287"


Remainder

Integers

remainderint

#Usage

std::string remainderint(std::string &x, std::string &x2)

#Description

Returns the remainder of a division between two int represented as a std string

#Arguments

NameDefinition
x is the int that will be divided, represented as a string, must be greater or equal to x2
x2 is the divider which is a int represented as a string, must be lower or equal to x

#Example(s)


std::string x = "1458970";
std::string x2 = "563489287";
remainderint(x2, x);
"326867"


Floating Points

remainderflt

#Usage

std::string remainderflt(std::string &x, std::string &x2)

#Description

Returns the remainder of a division between two int or floating point represented as a std string

#Arguments

NameDefinition
x is the floating point or int that will be divided, represented as a string, must be greater or equal to x2
x2 is the divider which is a floating point or int represented as a string, must be lower or equal to x

#Example(s)


std::string x = "14589.70";
std::string x2 = "56348.9287";
remainderflt(x2, x);
"12579.8287"


Quotient

Integers

quotientint

#Usage

std::string quotientint(std::string &x, std::string &x2)

#Arguments

NameDefinition
x is the int that will be divided, represented as a string.
x2 is the int that will divide x, represented as a string.

#Example(s)


std::string x = "1458970";
std::string x2 = "563489287";
quotientint(x2, x);
"386"


Floating points

quotientflt

#Usage

std::string quotientflt(std::string &x, std::string &x2)

#Arguments

NameDefinition
x is the int or floating point that will be divided, represented as a string.
x2 is the int or floating point that will divide x, represented as a string.

#Example(s)


std::string x = "14589.70";
std::string x2 = "563489.287";
quotientflt(x2, x);
"38"


Power

Integers

powerint3

#Usage

std::string powerint3(std::string &x, std::string &x2)

#Description

Returns the result of an int or float (as a std string) to the power of an int

#Arguments

NameDefinition
x is an int or float as a std string
x2 is an inst as a std string

#Example(s)


std::string x = "14589";
std::string x2 = "56";
powerint3(x, x2);
"153260190174219811934128
1373328279069291195584021
7380506021452271682252304
4456122073019142584098371
3668542386458635805076979
7750477593382226151659399
5310407783049191696069368
3775353015697068080493107
5377515793230902033635816
3020676961"


poweroddn

#Usage

std::string poweroddn(std::string &x, std::string &x2)

#Description

Returns the result of an int or float, as a std string to the power of 2 to the power of n, which is an int as a std string.

#Arguments

NameDefinition
x is the int or float (as a std string) that will be raised to the power of x2
x2 is an int

#Example(s)


std::string x = "14.589";
std::string x2 = "6";
poweroddn(x, x2);
"314509345202142665193410679
1254280331184383428647615863
43543406788602813321.8294140
3750171279036001626723680410
3022451365560402812257231544
5843033077900191220093294499
1283428303988674977649847362
2284482191189951072052752453
9081433388195244318415975907
58370489688259841"


Floating points

powerflt

#Usage

std::string powerflt(std::string &x, std::string &x2, unsigned int nb_polynomial = 20)

#Description

Returns the result of a int or float (as std string) to the power of int or float (as std string)

#Arguments

NameDefinition
x is the number (int or float as std string) that will be elevated to an exponent
x2 is the exponent (int or float as std string), can be negative
nb_polynomial is the length of the polynomial used for the taylor serie of exp(x) that allow the function to work. The bigger log(x) times x2 is, the bigger nb_polynomial should be.

#Example(s)


std::string x = "3.478";
std::string x2 = "10.58";
powerflt(x, x2);
"537525.0830373820"


Exponential

chexp1

#Usage

std::string chexp1(std::string x, int accuracy = 1000)

#Description

!!Not recommended, just a proof of concept!! Returns the result of an exponential. Works with the formula (1 + x/accuracy) ** accuracy

#Arguments

NameDefinition
x is the int or float that will be elevated to exponentiation
accuracy is the accuracy factor, the higher it is, the more precise it gets at a computational cost

#Example(s)


std::string x = "8";
chexp1(x);
"2887.5672632" // + lot of accuracy


chexp2

#Usage

std::string chexp2(std::string &x, unsigned int nb_polynomial = 21)

#Description

Returns the result of the exponential function for any value.

#Arguments

NameDefinition
x is the number (int or float as std string) that we want to calculate the exponential from
nb_polynomial is the length of the polynomial used for the taylor serie for the approximation of the exponential function. Higher x is, higher the value of this parameter should be.

#Example(s)


std::string x = "56.87";
chexp2(x, 390);
"1740896136763782323436009
23756492402749629488169224
00656258834086662691682597
94918287818150683946271409
01742656369685920125394044
39115388571203863053175373
76334830727566053789810167
11211770167759567751250865
97870411101884320489957750.4944500000"


chexp3

#Usage

std::string chexp3(std::string &x, std::string base = "2.7182818")

#Description

Returns the result of the exponential function from any int or float input (as std string).

#Arguments

NameDefinition
x is the input number (int or float as std string)
base is the string that designates exp(1), the more it is precise, the more the result will be precise at a computational cost

#Example(s)


std::string x = "700";
chexp3(x);
"10142246218121174560521
600483590985178822731162
265840307494321815475955
196440606121736950632710
229152857621236264315230
860476326255944650147652
743069711961041685242946
380185576276454807947772
716426832786438386678226
412457954326007771981274
482915225640041305958504
660920146680054469494665
672074795066594861.5716524393"


Logarithms

chlognatural1

#Usage

std::string chlognatural1(std::string &x)

#Description

Returns the result of the natural logarithm for any value.

#Arguments

NameDefinition
x is an int or float as std string, greater or equal to 1

#Example(s)


std::string x = "5687.58";
chlognatural1(x);
"8.646042"


Base n

chlogn

#Usage

std::string chlogn(std::string &x, std::string base)

#Description

Returns the value of a logarithm for any base.

#Arguments

NameDefinition
x is the value (int or float as std string) we want to find the logarithm from
base is the base (int or float as std string) of the logarithm

#Example(s)


std::string x = "5687.58";
std::string x2 = "10";
chlogn(x, x2);
"3.754931"


chlognabstraction

#Usage

std::string chlognabstraction(std::string &x, std::string &base)

#Description

Returns the result for logn(x)

#Arguments

NameDefinition
x is the input (int or float as std string)
base is the base of the log

#Example(s)

std::string x = "0.9";
std::string base = "1.570796";
chlognaturalabstraction(x, base);
"-0.152004"


chlognaturalabstraction

#Usage

std::string chlognaturalabstraction(std::string &x)

#Description

Returns the result for log(x)

#Arguments

NameDefinition
x is the input (int or float as std string)

#Example(s)

std::string x = "0.9";
chlognaturalabstraction(x);
"-0.105361"


Factorial

factorial

#Usage

std::string factorial(std::string &x)

#Description

Returns the factorial (of a positive integer number), represented as a std string

#Arguments

NameDefinition
x is an positive integer as a std string

#Example(s)


std::string x = "1203";
factorial(x);
"11029118227432030286833
5540036971957964398761
049288945189514522265
495848012966079388748
6066979739238579538633
40967082130666006801995
552084113814868238243311
8589137951547846171539022
96146662261034010473803
82756976753849367813834289
094730232788065976798962937
29705469953697890518296369
76020229377210033943230084
51633569924903385742877231
559110462395269386823689572
599108570915804023316767911
2351936991424971264582253948
7808873799678199393333955877
83920859359861012157863588005..."


Trigonometry

chcos

#Usage

std::string chcos(std::string &x, std::string base = "3.141593", unsigned int nb_polynom = 10)

#Description

Returns the result of cosinus(x) with the help of taylor serie

#Arguments

NameDefinition
x is the input number, int or float as std string
base is the closest value of 2 times pi
nb_polynom is the ssize of the polynom used for the approximation

#Example(s)

std::string x = "-125.5";
std::string final_rslt = chcos(x);
-0.9866278020907


chsin

#Usage

std::string chsin(std::string &x, std::string base = "6.283185", unsigned int n_polynom = 15)

#Description

Returns the result of sinus function.

#Arguments

NameDefinition
x is the input int of float as std string
base is the closest value to 2 times pi
n_polynom is the length of the polynom used by the taylor serie

#Example(s)

std::string x = "5.8";
std::string out = chsin(x);
"-0.464629431880273"


chtan

#Usage

std::string chtan(std::string &x, std::string base = "6.283185", unsigned int n_polynom = 10)

#Description

Returns the result of tan(x)

#Arguments

NameDefinition
x is the input number, int or float as std string
base is the closest value to 2 times pi
n_polynom is the length of the polynom used for the taylor approximation

#Example(s)

std::string x = "-3.5";
unsigned int nb = 10;
std::string base = "6.283185";
std::string out = chtan(x, base, nb);
"-0.374584"


chacos

#Usage

std::string chacos(std::string &x, std::string base = "1.570796", unsigned int n_polynom = 10)

#Description

Returns the result of acos(x)

#Arguments

NameDefinition
x is the input (int or float as std string)
base is the closest value to pi / 2
n_polynom is the size of the polynom used for the approximation of arcos with taylor serie

#Example(s)

std::string x = "-0.99";
chacos(x);
"3.00017080000"


chasin

#Usage

std::string chasin(std::string &x, std::string base = "1.570796", unsigned int n_polynom = 10)

#Description

Returns the result of asin(x)

#Arguments

NameDefinition
x is the input, int or float as std string
base is the closest value to pi/2
n_polynom is the size of the polynom used for the approximation by the taylor serie

#Example(s)

std::string x = "-0.97";
chasin(x);
"-1.32584700000"


chatan

#Usage

std::string chatan(std::string &x, unsigned int n_polynom = 10)

#Description

Returns the result of atan(x)

#Arguments

NameDefinition
x is the input int or float as std string
n_polynom is the length of the polynom used for the approximation with the taylor serie

#Example(s)

std::string x = "11.9";
chatan(x);
"1.489401"


Gamma function (decimal factorial)

chgamma

#Usage

std::string chgamma(std::string x)

#Description

Returns the result of gamma(x)

#Arguments

NameDefinition
x is the input, int or float as std string

#Example(s)

std::string x = "11.9";
std::string out = chgamma(x);
out = rmzero(out);
"31041633.57806124915329208135736
828050223671388095918020510420603
776136542459656770574445893880530
538152652348731494406662229882831
077376"


Beta function

chbeta

#Usage

std::string chbeta(std::string &x, std::string &x2)

#Description

Returns the result of the beta function

#Arguments

NameDefinition
x is the first input
y is the second input

#Example(s)

std::string x = "2";
std::string y = "3";
std::string out = chbeta(x, y);
"0.08333333"


Inverse functions

inverse

#Usage

std::string inverse(std::string &a, std::string &b, std::string (*f)(std::string&, std::string&))

#Description

Returns the inverse of the result of a function passed as a parameter.

#Arguments

NameDefinition
f is the function passed as a parameter
a is the first number, as a std string, of the function passed as a parameter
b is the second number, as a std string, of the function passed as a parameter

#Example(s)


std::string x = "3";
std::string x2 = "10";
inverse(x, x2, powerint3)
"0.0000169350" // is 1/3**10


Comparisons

is_greater

#Usage

bool is_greater(std::string &x, std::string &x2)

#Description

Returns 1 if the first number (int as a std string) is greater than the second (int as a std string) .

#Arguments

NameDefinition
x is a int as a string
x2 is a int as a string

#Example(s)


std::string x = "1203";
std::string x2 = "6";
is_greater(x, x2);
1


is_greaterflt

#Usage

bool is_greaterflt(std::string &x, std::string &x2)

#Description

Returns 1 if the first number, int or float (as a std string) is greater than the second, int or float (as a std string) .

#Arguments

NameDefinition
x is a number (int or float) as a string
x2 is a number (int or float) as a string

#Example(s)


std::string x = "1.203";
std::string x2 = "6";
is_greaterflt(x, x2);
0


Round

roundstr

#Usage

std::string roundstr(std::string &x, int &digits)

#Description

Round the input number entered as a std string.

#Arguments

NameDefinition
x is a std string representing a number
digits is the number of digits to round from, can be negative

#Example(s)


std::string x = "156.203";
int x2b = 2;
roundstr(x, x2b);
156.20
x2b = -1;
roundstr(x,; x2b);
160


Other Tools

rmzero

#Usage

std::string rmzero(std::string x)

#Description

Removes unnecessary 0 at the end of a floating point.

#Arguments

NameDefinition
is an float as a std string

#Example(s)


std::string x = "156.203000";
rmzero(x);
"156.203"


intpart

#Usage

std::string intpart(std::string x)

#Description

Returns the integer part of a float

#Arguments

NameDefinition
x is a float as a std string

#Example(s)


std::string x = "156.203";
intpart(x);
"156"


fltpart

#Usage

std::string fltpart(std::string &x)

#Description

Returns the float part of a float

#Arguments

NameDefinition
x is a float as a std string

#Example(s)


std::string x = "156.203";
fltpart(x);
"203"


is_decimal

#Usage

bool is_decimal(std::string &x)

#Description

Returns if a number as a std string, is a float

#Arguments

NameDefinition
x is the input number, as a std string

#Example(s)


std::string x = "156.203";
is_decimal(x);
1
x = "156";
is_decimal(x);
0


centerizer

#Usage

std::vector<std::string> centerizer(std::string x, std::string x2)

#Description

Returns the numerator and denominator transformed for the numerator to be higher or equal to 1

#Arguments

NameDefinition
x is the divided as a std string
x2 is the divider as a std string

#Example(s)


std::string x = "0.001562";
std::string x2 = "6.8987";
std::vector<std::string> out = centerizer(x, x2);
"1.562" "6898.7"


chabs

#Usage

std::string chabs(std::string &x)

#Description

Returns the absolute value of the input

#Arguments

NameDefinition
x is the input, a float or int as std string

#Example(s)

std::string x = "-0.645";
chabs(x);
"0.645"


is_zero

#Usage

bool is_zero(std::string &x)

#Description

Returns 1 if the input (int or float as std string) is equal to 0

#Arguments

NameDefinition
x the input number, int or float as std string

#Example(s)

std::string x = "0.007800";
is_zero(x);
0


About

C++ library to compute very large numbers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages