gitlabEdit

calc

calc command

Summary: You can calculate expressions

Description

If you need help on how to calculate expressions when multiplying and dividing large numbers, or if you need to calculate expressions faster, this command is for you.

It uses the Central Processing Unit (CPU) to process and evaluate expressions, and prints it on the screen when it's finished. You can't divide a number by zero.

It automatically determines whether it is Integer or Double by looking at expressions for decimals, and if one of the numbers has a decimal point, it switches the output of the expression to Double, otherwise, it will be Integer.

If you try to get past the overflow while there is no decimal points in your expression, it will result in the Integer Overflow error. A workaround is that you need to put a decimal point in one of the numbers.

You can also add parentheses for the expression that is inside it to be the top-priority as it is calculated in a PEMDAS form: Parentheses, Exponents, Multiplication, Division, Addition, Subtraction.

Command usage

  • calc (number) (+|-|*|/|%) (number) ...

  • calc ((number) (+|-||/|%) (number) ...) (+|-||/|%) (number) ...

Examples

  • calc 32 * 2048: This will multiply 32 by 2048, and the result is 65536

  • calc (128.50 - 42.25) / 2: This will evaluate expressions that are on the parentheses, then divides the result by 2, and the result is 43.13

  • calc 128.50 - 42.25 / 2: However, if you tried the above example without the parentheses, the 128.50 - 42.25 is no longer top-priority, and the result is 107.38

  • calc ((48.22 / 3.88) * (68.88 + 95.22)) + 9 - .41: This will evaluate this expression, and the result is 2048

  • calc 35 * 53: This will multiply 3 by 5 on the first part, and multiply 5 by 3 on the second part, then multiplies them, and the result is 225

  • calc (102410241024) * 2.0: This will multiply 1024 by 1024 by 1024, then multiplies it by 2 using the floating point processor, and the result is 2147483648.

Last updated