This script offers various math functions. It includes converting numbers from one base to another, factorials, exponentiation, combinations, and binomial probabilities. There's very little practical use for most of this, especially with zMUD's limitations, I really just made them for fun/practice. Instructions The most important thing to remember is that zMUD uses signed 32-bit integers, so it can't handle numbers higher than 2,147,483,647 or lower than −2,147,483,648. CONVERT <number> <start base> <end base>: Convert a number from one base to another. Any base from 2 to 64 will work. For bases higher than 10, 10-35 are A-Z, 36-61 are a-z, 62 and 63 are + and -. For base 36 and lower, it's not case sensitive, lowercase letters will be treated as capital letters. CONVERT <number> <base>: If you just list one base, it will convert the number from base 10 to the specified base. All of the rest are custom functions. @factor(X): Returns the factorial of X. For example, @factor(5) returns 120. Due to zMUD's limitations, it won't work with numbers higher than 12. @factordivide(X,Y): Returns the result of dividing X! by Y!. This is to get around zMUD's limitations. For example, @factordivide(5,3) is the same as 5!/3!, which returns 20. This is much less limited than a simple factorial, but it still won't be accurate if the result would be more than 2,147,483,647. @exponent(X,Y): Returns XY or X^Y. For example, @exponent(5,3) returns 125. You can use negative exponents as well, but zMUD isn't very precise with decimals, so it won't be perfectly accurate. @exponent(10,-2) returns 0.0100000007078052, instead of 0.01. The function won't work with non-integer exponents. @choose(X,Y): Returns "X choose Y" (also written as C(X,Y), XCY, XCY, etc.). For example, @choose(5,3) returns 10. Again, this is pretty limited. @biprob(A,X,Y,B): This function is fairly complicated. Basically, it returns the chance of getting X successes out of Y attempts, given B chance of success. A can be =, >, or <, and allows you to determine whether you want the chances of exactly X, at least X, or at most X. A and B are optional, and if left out, will be assumed to be = and 0.5, respectively. For example, @biprob(1,2) is the same as @biprob(=,1,2,0.5), which returns 0.5, which is the chance of exactly 1 success out of 2 attempts, given a 50% chance of success. @biprob(>,3,5,0.2) returns 0.0579200051724911, which is (roughly) the chance of 3 or more successes out of 5 attempts, given a 20% chance of success. This function is even more limited than most, due to the calculations involved. @or(X,Y): This simple function returns the chance of at least 1 success out of two attempts, with the two events having an X and Y chance of success. For example, @or(0.5,0.5) returns 0.75, @or(0.5,0.25) returns 0.625. This is the same as 1-((1-X)*(1-Y)). @ConvertFrom10(X,Y): Convert X from base 10 to base Y. Same limitations and 10+ numbering as the CONVERT alias. @ConvertTo10(X,Y): Convert X from base Y to base 10. Same limitations and 10+ numbering as the CONVERT alias. |