p!calculator - battlecatsultimate/PackPack GitHub Wiki

Type : Constraint Command
Level : Member
DM : Allowed


Alias

calc, c

Parameter

Formula [Required] : Formula that will be calculated. It must be formatted correctly, for example, opened bracket, or putting non-numeric letters other than recognized ones will make bot abort calculation process

  • Example : p!calculator 4 * 5, p!c sin(pi / 2) + log2(4)

Description

Calculating formula

Simple calculator. Below are supported formatting and functions. Inside of bracket means how you can write this element.


Numbers

  • Pi/π (pi|π)

Instead of writing 3.141592... manually, you can tell the bot that this number should be same with π by writing down pi. Bot considers this as raw number, so you can combine with other numbers altogether as well.

Example : p!c pi, p!c pi / 2

  • Euler's number/e (e)

Same like pi. Instead of writing 2.7182818..., you can write e to indicate that this number is supposed to be Euler's number.

Example : p!c e, p!c e * 3

  • Suffix (k/m/b/t)

Writing down numbers such as 12000000 is quite tedious thing to do. In this case, you can shorten number by writing suffix next to the value. For example, instead of 1000000, you can write 1m (meaning 1 million). Then bot will consider this value as 1000000. It supports up to trillion.

Example : p!c 100k, p!c 1m / 1k


Operators

Operators won't need explanation, so only elements will be listed.

  • Addition (+)

Example : p!c 1 + 1

  • Subtraction (-)

Example : p!c 1 - 1

  • Multiplication (*|×|x [Alphabet x])

Example : p!c 1 * 1, p!c 1 × 1

  • Division (/|÷)

Example : p!c 1 / 1, p!c 1 ÷ 1

  • Powers (^)

Example : p!c 1 ^ 1

  • Brackets (()|{}|[])

Example : p!c 2 * (1 + 4), p!c 2 * (1 + 4 * (3 + 2)), p!c 2 * [1 + 4 * {3 + 2 * (4 + 5)}]

  • Absolute (||)

Example : p!c |5 - 10|

Example : p!c 5!, p!c (5 * 2)!


Functions

  • sin (sin(value))

Trigonometric functions sin, you have to put values or formula in the bracket of sin function.

Example : p!c sin(pi), p!c sin(3 * pi / 2)

  • cos (cos(value))

Trigonometric functions cos, you have to put values or formula in the bracket of cos function.

Example : p!c cos(0), p!c cos(3 * pi / 2)

  • tan (tan(value))

Trigonometric functions tan, you have to put values or formula in the bracket of tan function. Result of formula, or value that gets put in this function must not be multiplies of π/2.

Example : p!c cos(0), p!c cos(3 * pi / 2)

  • csc (csc(value))

Trigonometric functions csc, you have to put values or formula in the bracket of csc function. Result of formula, or value that gets put in this function must not be multiplies of π.

Example : p!c csc(pi / 2), p!c csc(pi / 4)

  • sec (sec(value))

Trigonometric functions sec, you have to put values or formula in the bracket of sec function. Result of formula, or value that gets put in this function must not be multiplies of π/2.

Example : p!c sec(1), p!c sec(pi)

  • cot (cot(value))

Trigonometric functions cot, you have to put values or formula in the bracket of cot function. Result of formula, or value that gets put in this function must not be multiplies of π. If said inner value turned out to be multiplies of π/2, bot will return 0.

Example : p!c cot(pi/2), p!c cot(pi/4)

  • arcsin (arcsin(value)|asin(value))

Inverse trigonometric functions arcsin, you have to put values or formula in the bracket of arcsin function. Result of formula, or value that gets put in this function must be in range of -1 ≤ x ≤ 1

Example : p!c arcsin(0), p!c asin(1)

  • arccos (arccos(value)|acos(value))

Inverse trigonometric functions arcsin, you have to put values or formula in the bracket of arcsin function. Result of formula, or value that gets put in this function must be in range of -1 ≤ x ≤ 1

Example : p!c arccos(0), p!c acos(0.5)

  • arctan (arctan(value)|atan(value))

Inverse trigonometric functions arctan, you have to put values or formula in the bracket of arctan function.

Example : p!c arctan(0), p!c atan(1)

  • arccsc (arccsc(value)|acsc(value))

Inverse trigonometric functions arccsc, you have to put values or formula in the bracket of arccsc function. Result of formula, or value that gets put in this function must be in range of x ≤ -1, 1 ≤ x

Example : p!c arccsc(1), p!c acsc(2)

  • arcsec (arcsec(value)|asec(value))

Inverse trigonometric functions arcsec, you have to put values or formula in the bracket of arcsec function. Result of formula, or value that gets put in this function must be in range of x ≤ -1, 1 ≤ x

Example : p!c arcsec(1), p!c asec(2)**

  • arccot (arccot(value)|acot(value))

Inverse trigonometric functions arccot, you have to put values or formula in the bracket of arccot function. If result of formula, or value that get put in this function is 0, bot will return π/2.

Example : p!c arccot(1), p!c acot(0)

Absolute value of input value. This can be performed via wrapping value or formula with | as well.

Example : p!c abs(-1), p!c abs(-2 * 4)

Sign function returns 1 if value is positive, -1 if value is negative, 0 if value is 0.

Example : p!c sign(2), p!c sgn(-50)

Floor function sets the value to lowest nearby integer. For example, floor(-1.5) is -2, floor(5.5) is 5.

Example : p!c floor(-1.5)

Round function that uses Half up logic. This isn't same with scientific rounding. For example, round(2.5) is 3, round(-2.6) is -3.

Example : p!c round(2.5)

Ceil function sets the value to highest nearby integer. For example, ceil(-1.5) is -1, ceil(5.001) is 6.

Example : p!c ceil(5.001)

This command doesn't refer log as natural logarithm, you have to use ln to use this function. Result of formula, or the value that gets put in the bracket must not be negative or 0.

Example : p!c ln(e)

Just passing log will make bot use logarithm function with base of 10. Just like any logarithm functions, the value or formula in the bracket must not be negative or 0.

Example : p!c log(100)

  • Logarithm with base of N (logN(value))

When you want to specify the base of this function, you have to write number next to log. For example, if you want to set base as 2, you have to write down like this : log2(value). Writing down pi or e works, but it doesn't accept formula as base. Base can't be negative value, and the value or formula that will be put in the bracket must not be negative or 0.

Example : p!c log2(4), p!c logpi(pi^2)

The value or formula that will be put in the bracket must not be negative.

Example : p!c sqrt(4), p!c sqrt(9)

Instead of square root, when you want to use Nth root instead, you have to write down next to sqrt (It's for convenience even though it's sqrt). For example, cube root will be sqrt3(value)

Example : p!c sqrt3(8), p!c sqrt10(1024)

This performs same thing as e^x.

Example : p!c exp(2)

This function requires two formula, or value unlike any other functions. For example, if you want to specify n as 5, and r as 3, you can write down either 5p3, or npr(5, 3)

Example : p!c npr(5 * 2, 3), p!c 7p2

Similar like permutation function, you have to write down either 5c3 or ncr(5, 3)

Example : p!c ncr(5 * 2, 3), p!c 7c2

⚠️ **GitHub.com Fallback** ⚠️