Post by chris857 on Aug 6, 2010 21:40:18 GMT -5
GMP plugin
I've made a plugin for several functions from the GNU Multiple Precision library. It is a library that allows for any size number without losing precision. So far, I've only implemented some of the more important integer functions.
result$ = gmpIntAdd(num1$,num2$)
result$ = gmpIntSubtract(num1$,num2$)
result$ = gmpIntMultiply(num1$,num2$)
result$ = gmpIntDivide(num1$,num2$)
result$ = gmpIntAbs(num1$)
result$ = gmpIntNegate(num1$)
result$ = gmpIntMod(num1$,num2$)
(aka '%' operator)
result$ = gmpIntPow(num1$,num2$)
result$ = gmpIntSqr(num1$)
result$ = gmpIntRoot(num1$,num2$)
(returns num1$ to the num2$'th root)
result = gmpIntSgn(num1$)
(acts just like sgn())
result = gmpIntCompare(num1$,num2$)
(if num1$ < num2$, then result = -1; if num1$ = num2$, then result = 0; else result = 1)
result$ = gmpIntRand(num1$)
(creates a random number between 0 and num1$-1)
result$ = gmpIntGCD(num1$,num2$)
(returns the greatest common denominator of num1$ and num2$)
result$ = gmpIntLCM(num1$,num2$)
(returns the least common multiple of num1$ and num2$)
result$ = gmpIntFactorial(num1$)
Bit-wise Operators
result$ = gmpIntAND(num1$,num2$)
result$ = gmpIntOR(num1$,num2$)
result$ = gmpIntXOR(num1$,num2$)
result$ = gmpIntNOT(num1$,num2$)
I hope someone finds this useful.
Note: Even though num1$ and num2$ are strings, integers can be passed to these functions instead. Also, if the numbers sent as arguments are too large, the function will take a long time to complete.
I've made a plugin for several functions from the GNU Multiple Precision library. It is a library that allows for any size number without losing precision. So far, I've only implemented some of the more important integer functions.
result$ = gmpIntAdd(num1$,num2$)
result$ = gmpIntSubtract(num1$,num2$)
result$ = gmpIntMultiply(num1$,num2$)
result$ = gmpIntDivide(num1$,num2$)
result$ = gmpIntAbs(num1$)
result$ = gmpIntNegate(num1$)
result$ = gmpIntMod(num1$,num2$)
(aka '%' operator)
result$ = gmpIntPow(num1$,num2$)
result$ = gmpIntSqr(num1$)
result$ = gmpIntRoot(num1$,num2$)
(returns num1$ to the num2$'th root)
result = gmpIntSgn(num1$)
(acts just like sgn())
result = gmpIntCompare(num1$,num2$)
(if num1$ < num2$, then result = -1; if num1$ = num2$, then result = 0; else result = 1)
result$ = gmpIntRand(num1$)
(creates a random number between 0 and num1$-1)
result$ = gmpIntGCD(num1$,num2$)
(returns the greatest common denominator of num1$ and num2$)
result$ = gmpIntLCM(num1$,num2$)
(returns the least common multiple of num1$ and num2$)
result$ = gmpIntFactorial(num1$)
Bit-wise Operators
result$ = gmpIntAND(num1$,num2$)
result$ = gmpIntOR(num1$,num2$)
result$ = gmpIntXOR(num1$,num2$)
result$ = gmpIntNOT(num1$,num2$)
I hope someone finds this useful.
Note: Even though num1$ and num2$ are strings, integers can be passed to these functions instead. Also, if the numbers sent as arguments are too large, the function will take a long time to complete.