Skip to content

NCalc Functions

Excerpts from NCalc docs - Operators

The framework includes a set of already implemented functions.

NameDescriptionUsageResult
AbsReturns the absolute value of a specified number.Abs(-1)1d
AcosReturns the angle whose cosine is the specified number.Acos(1)0d
AsinReturns the angle whose sine is the specified number.Asin(0)0d
AtanReturns the angle whose tangent is the specified number.Atan(0)0d
CeilingReturns the smallest integer greater than or equal to the specified number.Ceiling(1.5)2d
CosReturns the cosine of the specified angle.Cos(0)1d
ExpReturns e raised to the specified power.Exp(0)1d
FloorReturns the largest integer less than or equal to the specified number.Floor(1.5)1d
IEEERemainderReturns the remainder resulting from the division of a specified number by another specified number.IEEERemainder(3, 2)-1d
LnReturns the natural logarithm of a specified number.Ln(1)0d
LogReturns the logarithm of a specified number.Log(1, 10)0d
Log10Returns the base 10 logarithm of a specified number.Log10(1)0d
MaxReturns the larger of two specified numbers.Max(1, 2)2
MinReturns the smaller of two numbers.Min(1, 2)1
PowReturns a specified number raised to the specified power.Pow(3, 2)9d
RoundRounds a value to the nearest integer or specified number of decimal places. The mid number behaviour can be changed by using ExpressionOptions.RoundAwayFromZero during construction of the Expression object.Round(3.222, 2)3.22d
SignReturns a value indicating the sign of a number.Sign(-10)-1
SinReturns the sine of the specified angle.Sin(0)0d
SqrtReturns the square root of a specified number.Sqrt(4)2d
TanReturns the tangent of the specified angle.Tan(0)0d
TruncateCalculates the integral part of a number.Truncate(1.7)1

Doc editor:
The unit of measurement related to trigonometric functions is radian.
Thedafter numbers in the result is to indicate that the number is a double-precision floating point number.
TheRountfunction with two parameters will give strange results, and it's not solved.

It also includes other general purpose ones.

NameDescriptionUsageResult
inReturns whether an element is in a set of values.in(1 + 1, 1, 2, 3)true
ifReturns a value based on a condition.if(3 % 2 = 1, 'value is true', 'value is false')'value is true'
ifsReturns a value based on evaluating a number of conditions, returning a default if none are true.ifs(foo > 50, "bar", foo > 75, "baz", "quux")if foo is between 50 and 75 "bar", foo greater than 75 "baz", otherwise "quux"

You can use comma,or semicolon;as argument separator.

Doc editor: You must use,as argument separator in the Gigavolt Truth Table.