CCalc  Console Command Line Calculator utility

Copyright MMIX-MMXVIII Roberto Bianchi

Softspecialists - www.softspecialists.com

Introduction

CCalc is a Windows console program that will let you to quickly perform some calculation.

Besides the traditional operators are available advanced mathematical, trigonometrics and conversion functions.

CCalc requires at least Windows 2000, Windows XP, Windows Server 2003 and Windows Vista or above.

Using CCalc

You should start CCalc from command prompt or from another program or batch.

Command Line Options

CCalc supports th supports the following command-line options:

usage: CCalc [MathExpression] | [/f:InputFile [/s]]

 

MathExpression

the mathematical expression to calculate. It's a combination of mathematical symbols can designate numbers and one or more operators or functions shown below.

 

/f:InputFile

Read the MathExpression from the InputFile, all lines are merged into one line before perform a calculation.

 

/s

Used with /f option it forces to perform calculation to each single file's row.

     

If you run ace="Verdana" class="hcp2">CSCCalc without any parameter you get the following utility help:

MATHEMATICAL OPERATORS:

 

+

Addition.

 

Subtraction and negation.

 

*

Multiplication.

 

/

Division.

 

^

Exponentiation.

 

()

Parentheses.

 

AND

Bitwise AND arithmetic operator.

 

MOD

Calculate the remainder of the division.

 

OR

Bitwise OR arithmetic operator.

 

XOR

Bitwise XOR arithmetic operator.

MATHEMATICAL FUNCTIONS:

 

ABS

Returns the absolute value.

 

EXP

Returns e raised to the nth power.

 

EXP2

Returns 2 raised to the nth power.

 

EXP10

Returns 10 raised to the nth power.

 

FACT

Returns the factorial.

 

FRAC

Returns the fractional part.

 

INT

Returns the integer part

 

LC

Returns the value obtained by the last (valid) calculation. Available only from version 1.2.

 

LN

Returns the natural (base e) logarithm.

 

LOG

Returns the common (base 10) logarithm.

 

LOG2

Returns the base 2 logarithm.

 

MAX

Returns the maximum value between 2 values.

 

MIN

Returns the minimum value between 2 values.

 

NOT

Returns the bitwise NOT.

 

POW

Returns the power (exponentiation).

 

RND

Returns a random value.

 

ROUND

Returns then rounded value.

 

SQR

Returns the square root.

 

SUM

Returns the summatory.

TRIGONOMETRICT FUNCTIONS:

 

ACOS

Returns the inverse cosine.

 

ACOSH

Returns the inverse hyperbolic cosine.

 

ASIN

Returns the inverse sine.

 

ASINH

Returns the inverse hyperbolic sine.

 

ATAN

Returns the Inverse Tangent.

 

ATANH

Returns the Inverse Hyperbolic Tangent.

 

COS

Returns the Cosine of an angle specified in degree.

 

COSH

Returns the Hyperbolic Cosine.

 

PI

Returns the pi value.

 

SIN

Returns the Sine of an angle specified in degree.

 

SINH

Returns the Hyperbolic Sine.

 

TAN

Returns the Tangent of an angle specified in degree.

 

TANH

Returns the Hyperbolic Tangent.

CONVERSION FUNCTIONS:

 

DEG

Converts Radians To Degrees.

 

RAD

Converts Degrees To Radians.

 

METER2FEET

Converts METER to FEET.

 

FEET2METER

Converts FEET to METER.

 

MILE2FEET

Converts MILE to FEET.

 

FEET2MILE

Converts FEET to MILE.

 

INCH2CM

Converts INCH to CENTIMETRE.

 

CM2INCH

Converts CENTIMETRE to INCH.

 

MILE2YARD

Converts MILE to YARD.

 

YARD2MILE

Converts YARD to MILE.

 

MILE2KM

Converts MILE to KILOMETER.

 

KM2MILE

Converts KILOMETER to MILE.

 

GALLON2LITRE

Converts US GALLON to LITRE.

 

LITRE2GALLON

Converts LITRE to US GALLON.

 

FOOT2INCH

Converts FOOT to INCH.

 

INCH2FOOT

Converts INCH to FOOT.

 

OUNCE2GRAM

Converts OUNCE to GRAM.

 

GRAM2OUNCE

Converts GRAM to OUNCE.

 

POUND2OUNCE

Converts POUND to OUNCE.

 

OUNCE2POUND

Converts OUNCE to POUND.

 

KG2POUND

Converts KILOGRAM to POUND.

 

POUND2KG

Converts POUND to KILOGRAM.

 

FAHR2CELS

Converts FAHRENHEIT to CESIUS degree.

 

CELS2FAHR

Converts CESIUS to FAHRENHEIT degree.

OTHERS FUNCTIONS:

 

DWORD

Makes a double word and returns it.

 

HIB

Extract the hight BYTE from a WORD value.

 

HIW

Extract the hight WORD from a DWORD value.

 

LOB

Extract the low BYTE from a WORD value.

 

LOW

Extract the low WORD from a DWORD value.

 

SECINDAY

Returns the number of seconds in the whole day.

 

WORD

Makes a word and returns it.

EXAMPLES:

 

ccalc pi()

=3.14159265358979

 

ccalc 1+LC()

=5

 

ccalc sin(360)+1*(sqr(4)+3)

=6

 

ccalc (1234+5678)xor(1+24)

=6937

 

ccalc not(0)

=-1

 

ccalc sum(100)+fact(7)

=10090

 

ccalc 10 mod 3

=1

 

ccalc 2^^2

=4

 

ccalc pow(2,3)

=8

 

ccalc round(1.2345,2)

=1.23

 

ccalc word(1,1)

=257

 

ccalc min(pow(10,2),100*2)/10

=10

 

ccalc cels2fahr(25)

=77

 

ccalc /f:AllRowsInOne.txt

read the espression from all rows of the file

 

ccalc /f:EachRowSingle.txt /s

perfom an evaluation for each row of the file

 

If both AllRowsInOne.txt and EachRowSingle.txt contain the following 3 lines:

 

 

10+1

 

 

9*3

 

 

8/2

 

 

The results for 'ccalc /f:AllRowsInOne.txt' execution will be:

=371

 

And for '/f:EachRowSingle.txt /s':

=11

 

 

=27

 

 

=4

Note

Starting from the version 1.2.0.0 the CCalc utility is build on matheval.dll that is a lightweight math parser that provide all functionalities with just few functions.

Return Value

CCalc returns -2147483648 if fails, otherwise returns the result of calculation as signed long integer in the range from -2147483647 to +2147483647 that you can use with the %ERRORLEVEL% variable.