Rob van der Woude's Scripting Pages

Help text for ClCalc.cs

(view help text of ClCalc.cs as plain text)

ClCalc.exe,  Version 2.01
Command Line Calculator

Usage:     CLCALC  [ expression ]  [ /DEBUG ]

Run the program without expression to open an interactive console.

Available Operators:
====================
+ - * / % << >> & |

Available Constants:
====================
Math.PI (pi) and Math.E (e)

Available Functions:
====================
Math.Abs            Math.Acos           Math.Asin           Math.Atan
Math.Atan2          Math.BigMul         Math.Ceil *         Math.Ceiling
Math.Cos            Math.Cosh           Math.Exp            Math.Floor
Math.IEEERemainder  Math.Int *          Math.Log            Math.Log10
Math.Max            Math.Min            Math.Pow            Math.Round
Math.Sign           Math.Sin            Math.Sinh           Math.Sqrt
Math.Tan            Math.Tanh           Math.Truncate       Random *

* Math.Ceil is equivalent of Math.Ceiling, Math.Int of Math.Truncate;
  these equivalents were created for backwards compatibility with ClCalc 1.*
  Random is an added function, not part of the .NET System.Math class but of
  the .NET System.Random class.
  Function names are not case sensitive, but constants e and pi are.
  The Math. prefix is not mandatory in the input, except for upper case
  Math.E and Math.PI.



For more details on functions and parameters, navigate to:
https://learn.microsoft.com/en-us/dotnet/api/system.math?view=netframework-4.5

EXAMPLES
========

Expression:                           Evaluates To:         Remark:
===========                           =============         =======
"%var1% & %var2%"                      0 or 1               AND operator
"%var1% | %var2%"                      0 or 1               OR operator
"16 >> 1"                              8                    shift right
"16 << 2"                             64                    shift left
"16 % 3"                               1                    use whitespace!
Math.Abs( -12 )                       12
Math.Acos( 0.707106781186548 )         0.785398163397448
Math.Asin( 0.707106781186548 )         0.785398163397448
Math.Atan( 1 )                         0.785398163397448
Math.Atan2( 1, 1 )                     0.785398163397448
Math.BigMul( 2147483647, 2147483647 )  4.61168601413242E+18 Int64 result
Math.Ceiling( Math.PI )                4                    round up to int
Math.Cos( pi / 4 )                     0.707106781186548
Math.Cosh( 1 )                         1.54308063481524
Math.Exp( -1 ) * Math.E                1
Math.Floor( Math.E )                   2                    round down to int
Math.IEEERemainder( 4, 3 )             1                    like   "4 % 3"
Math.IEEERemainder( 5, 3 )            -1                    unlike "5 % 3"
Math.Log( Math.E )                     1                    natural logarithm
Math.Log10( 1000 )                     3                    base 10 logarithm
Math.Max( -10, -12 )                 -10
Math.Min( -10, -12 )                 -12
Math.Pow( 2, 8 )                     256
Math.Round( 12.5 )                    13
Math.Sign( -3 )                       -1
Math.Sin( pi / 4 )                     0.707106781186548
Math.Sinh( 1.5 )                       2.12927945509482
Math.Sqrt( 9 )                         3
Math.Tan( pi / 4 )                     1
Math.Tanh( 2 )                         0.964027580075817
Math.Truncate( -12.6 )               -12
Random( )                              0 <= result < 1      floating point
Random( 100 )                          0 <= result < 100    integer
Random( 1, 101 )                       1 <= result < 101    integer
pi / Math.Acos( Math.Pow(0.5, 0.5) )   4                    nested Math calls
			
Notes:
======
In non-interactive mode, the result is shown on screen and the exit code
("errorlevel") equals the rounded value of result, or 0 in case of
error or overflow.
In non-interactive mode, the result is shown in Standard Output stream,
and the initial expression in Standard Error stream, to allow capturing
or redirection of the result only.
In interactive console mode type DEBUG to toggle debug mode.
If expression contains special characters like < or > or | or & it is
highly recommended to enclose the entire expression in doublequotes and
use whitespace around these operators, e.g. "16 << 1".
Available constants are case sensitive, function names are not.
"Math.PI" may be abbreviated to "pi" (lower case), "Math.E" to "e".
In ClCalc all Math functions are limited to 2 parameters at most, usually of
types Double or Int32.
This program requires .NET Framework 4.5.
Culture is set to en-US, so use and expect decimal dots, not commas.
See this web page for methods available in .NET's Math class:
https://learn.microsoft.com/en-us/dotnet/api/system.math?view=netframework-4.5

Credits:
========
Originally based on Eval function (using JScript) by "markman":
https://www.codeproject.com/Articles/11939/Evaluate-C-Code-Eval-Function

Written by Rob van der Woude
https://www.robvanderwoude.com

page last uploaded: 2022-10-05; loaded in 0.0201 seconds