13.11.2012, 15:36
(
Последний раз редактировалось Johnson_boy; 18.12.2016 в 10:49.
)
Numlib
THIS LIBRARY IS NO LONGER MAINTAINED.
The source code is available here.
What is this and why would I use it?
Numlib is a SA-MP library for dealing with numbers greater than 2 147 483 647,
which means numbers greater than 32-bit numbers. The library allows you to
perform basic mathematical operations (add and subtract at the moment) with
integers in form of strings, which is the reason why this library is able to
handle almost any numbers.
So if you need to deal with big numbers, greater than one billion, this library
might be useful for you.
Functions
add:
subtract:
multiply
num_power
divide
get_remainder
is_greater
is_less
Example
THIS LIBRARY IS NO LONGER MAINTAINED.
The source code is available here.
What is this and why would I use it?
Numlib is a SA-MP library for dealing with numbers greater than 2 147 483 647,
which means numbers greater than 32-bit numbers. The library allows you to
perform basic mathematical operations (add and subtract at the moment) with
integers in form of strings, which is the reason why this library is able to
handle almost any numbers.
So if you need to deal with big numbers, greater than one billion, this library
might be useful for you.
Functions
add:
Код:
Add two integers Parameters: number1[] An integer represented as a char array number2[] An integer represented as a char array Returns: The sum of number1 and number2 as a char array
Код:
Subtract two integers Parameters: number1[] An integer represented as a char array number2[] An integer represented as a char array Returns: The remainder of substraction of number1 and number2 as a char array
Код:
Multiply two numbers Parameters: number1[] An integer represented as a char array number2[] An integer represented as a char array Returns: The result of the multiplication as a char array
Код:
Raise number (char array) to the power of another number (32-bit integer) Parameters: number1[] An integer represented as a char array power A 32-bit integer Returns: The result of the power as a char array
Код:
Divide a number (char array) by another number (32-bit integer) Parameters: divident[] An integer represented as a char array divisor A 32-bit integer Returns: The result of the division as a char array. The result is always an integer, and the remainder can be obtained using get_remainder function.
Код:
Get the remainder of a division. Works similarly to modulus (%). Parameters: divident[] An integer represented as a char array divisor A 32-bit integer Returns: The remainder of the division as a 32-bit integer
Код:
Compares two char arrays (as if they were numbers) and determines whether the first one is greater than the second or not Parameters: number1[] An integer represented as a char array number2[] An integer represented as a char array Returns: boolean: true or false
Код:
Compares two char arrays (as if they were numbers) and determines whether the first one is smaller than the second or not Parameters: number1[] An integer represented as a char array number2[] An integer represented as a char array Returns: boolean: true or false
pawn Код:
new integer1[20], integer2[20];
integer1 = "1000000000000000000";
integer2 = "5320010493843209492";
printf("Result: %s", add(integer1, integer2));
// Output: Result: 6320010493843209492