[Home]
   [Commands]   [Downloads]   [Egghelp]   [History]   [Policies]
 

Issuing Commands

Levels of Access

Tutorials

Commands for:
Anyone
ChanVoice
ChanOp
ChanMaster
ChanOwner

Addon Features


 
Calc Tutorial

The functions of the CALC command are not dissimilar to those of a professional scientific calculator, with a focus on more commonly observed mathematic principles.
 

Intent

The calc command is used to evaulate any valid expression given to the bot and will return the result to the channel in which the command was used. If the command was used via msg, the bot will then return the result to the user via notice.
 

Usage

The command may be issued in one of two ways.

                   botnick calc expression
or     /msg botnick calc #channel expression
 

Arguments

A valid expression may include

  • A numeric value, (integer or floating-point).
  • A mathematical function, of a type listed below.
Any of the following operators may be used (grouped in decreasing order of precedence);
 
  • -  +  ~  !

  • Unary minus, unary plus, bit-wise NOT, logical NOT. None of these operands may be applied to string operands, and bit-wise NOT may be applied only to integers.
  • *  /  %

  • Multiply, divide, remainder. None of these operands may be applied to string operands, and remainder may be applied only to integers. The remainder will always have the same sign as the divisor and an absolute value smaller than the divisor.
  • +  -

  • Add and subtract. Valid for any numeric operands.
  • <<  >>

  • Left and right shift. Valid for integer operands only. A right shift always propagates the sign bit.
  • < >  <=  >=
    Boolean less, greater, less than or equal, and greater than or equal. Each operator produces 1 if the condition is true, 0 otherwise. These operators may be applied to strings as well as numeric operands, in which case string comparison is used.
  • ==  !=

  • Boolean equal and not equal. Each operator produces a zero/one result. Valid for all operand types.
  • &

  • Bit-wise AND. Valid for integer operands only.
  • ^

  • Bit-wise exclusive OR. Valid for integer operands only.
  • |

  • Bit-wise OR. Valid for integer operands only.
  • &&

  • Logical AND. Produces a 1 result if both operands are non-zero, 0 otherwise. Valid for boolean and numeric (integers or floating-point) operands only.
  • ||

  • Logical OR. Produces a 0 result if both operands are zero, 1 otherwise. Valid for boolean and numeric (integers or floating-point) operands only.
  • x?y:z

  • If-then-else. If x evaluates to non-zero, then the result is the value of y. Otherwise the result is the value of z. The x operand must have a numeric value.


Any of the following mathematical functions may be used;
 

  • abs(arg)

  • Returns the absolute value of arg. Arg may be either integer or floating-point, and the result is returned in the same form.
  • acos(arg)

  • Retur
    Free Web Hosting