[Home]
Site Meter
[Applications]   [Classes]   [Commands]   [Downloads]   [Egghelp]   [Features]   [Help]   [Information]   [Links]   [News]   [Policies]   [Staff]
 

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)

  • Returns the arc cosine of arg, in the range [0,pi] radians. Arg should be in the range [-1,1].
  • asin(arg)

  • Returns the arc sine of arg, in the range [-pi/2,pi/2] radians. Arg should be in the range [-1,1].
  • atan(arg)

  • Returns the arc tangent of arg, in the range [-pi/2,pi/2] radians.
  • atan2(x, y)

  • Returns the arc tangent of y/x, in the range [-pi,pi] radians. x and y cannot both be 0.
  • ceil(arg)

  • Returns the smallest integer value not less than arg.
  • cos(arg)

  • Returns the cosine of arg, measured in radians.
  • cosh(arg)

  • Returns the hyperbolic cosine of arg.
  • double(arg)

  • If arg is a floating value, returns arg, otherwise converts arg to floating and returns the converted value.
  • exp(arg)

  • Returns the exponential of arg, defined as e**arg.
  • floor(arg)

  • Returns the largest integral value not greater than arg.
  • fmod(x, y)

  • Returns the floating-point remainder of the division of x by y. If y is 0, an error is returned.
  • hypot(x, y)

  • Computes the length of the hypotenuse of a right-angled triangle (x*x+y*y).
  • int(arg)

  • If arg is an integer value, returns arg, otherwise converts arg to integer by truncation and returns the converted value.
  • log(arg)

  • Returns the natural logarithm of arg. Arg must be a positive value.
  • log10(arg)

  • Returns the base 10 logarithm of arg. Arg must be a positive value.
  • pow(x, y)

  • Computes the value of x raised to the power y. If x is negative, y must be an integer value.
  • rand()

  • Returns a floating point number from zero to just less than one or, in mathematical terms, the range [0,1].
  • round(arg)

  • If arg is an integer value, returns arg, otherwise converts arg to integer by rounding and returns the converted value.
  • sin(arg)

  • Returns the sine of arg, measured in radians.
  • sinh(arg)

  • Returns the hyperbolic sine of arg.
  • sqrt(arg)

  • Returns the square root of arg. Arg must be non-negative.
  • tan(arg)

  • Returns the tangent of arg, measured in radians.
  • tanh(arg)

  • Returns the hyperbolic tangent of arg.


Examples

  • Determining the length of the hypotenuse of a right-angled triangle where the known sides are of length 6cm and 8cm.

  • botnick calc sqrt(pow(6,2) + pow(8,2))
    Infact, we can save ourselves some typing by using
    botnick calc hypot(6,8)
   

©1998 - 2005 BotService