Use Shang as an arbitrary precision calculator

The interpreter can be used as a calculator. An arithmetic expression can be entered like in other programming languages, and after enter is hit, the interpreter will return the value of the expression. An expression is similar to those found in math books and can contain numbers and operators +, -, *, and / that represent addition, subtraction, multiplication respectively, and division, and parentheses can be used for grouping. For example
>> (1 + sqrt(5)) / 2
   1.618033989

The value of a^b is raised to the power of .

>> 81^(1/2)
    9

Most common elementary functions such as sqrt, exp, log, sin, cos, tan, asin, acos, and atan can be used in the expressions.

Complex numbers are supported directly. A complex number of real and imaginary parts a and b is displayed as a+bi, and can be entered as either a+bi, a+bI, a+bj, or a+bJ. For example

>> sqrt(-5)
    0 + 2.236067977i
>> (3+5i) / (2-3j)
    -0.6923076923 + 1.461538462i

If a constant has the M suffix, it is treated as a multi-precision floating point number. By default, it is stored with 128 binary digits. For example

>> (1 + sqrt(5M)) / 2
   1.61803398874989484820458683436563E0

oz 2009-12-22