AlliedBits.NCalc 8.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AlliedBits.NCalc --version 8.5.0
                    
NuGet\Install-Package AlliedBits.NCalc -Version 8.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AlliedBits.NCalc" Version="8.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlliedBits.NCalc" Version="8.5.0" />
                    
Directory.Packages.props
<PackageReference Include="AlliedBits.NCalc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AlliedBits.NCalc --version 8.5.0
                    
#r "nuget: AlliedBits.NCalc, 8.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AlliedBits.NCalc@8.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AlliedBits.NCalc&version=8.5.0
                    
Install as a Cake Addin
#tool nuget:?package=AlliedBits.NCalc&version=8.5.0
                    
Install as a Cake Tool

NCalc is a fast and lightweight expression evaluator library for .NET, designed for flexibility and high performance. It supports a wide range of mathematical and logical operations. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions. NCalc targets .NET 9, .NET 8, .NET Standard 2.0, and NET Framework 4.6.2 and later.

Advanced features

This branch of NCalc contains a number of advanced features compared to the original NCalc project, such as

  • Assignable parameters (variables) including shortcut operators (+=, etc.).
  • Statement sequences (useful together with parameter assignments) which, in expressions, may be grouped using curly brackets (like in C-like languages).
  • Support for indexed expressions (when an expression evaluates to a list a string, it is possible to access individual elements or a range of elements and assign new values of individual elements).
  • Support for loops using the 'while' loop statement (it follows the regular C-like style) with 'break' and 'continue' flow control keywords.
  • Support for the 'if' statement, which follows the regular C-like style.
  • Support for C-Style (line and block) and Python-style comments.
  • User-defined functions with named parameters (right in the expression, yes).
  • The 'return' flow control keyword that lets one return a value without completely evaluating the expression (useful in complex expressions with multiple statements, conditions, or loops, as well as with user-defined functions).
  • Advanced date and time parsing, which takes into account culture settings (current or specific culture or custom separators) and supports times with or without seconds as well as 12-hour time.
  • Parsing of humane period expressions like "3 weeks 2 days 5 hours" (period identifiers are customizable and multiple identifier per period are supported).
  • Basic calculations with dates and time spans - one can add and subtract dates and times. Without these operations, date and time values are of little use (if only with custom functions).
  • Currency support, which takes into account culture settings (current or specific culture or custom symbols) and produces decimal result from the currency value.
  • Optional use of BigInteger and BigDecimal types for basic math operations and most built-in funcitons.
  • Underscores in numbers and currency values. Modern programming languages support underscores for readability. Support is built-in with binary, octal, and hex numbers, while support in decimal numbers requires a custom branch of Parlot.
  • Custom decimal and group separators in numbers and currency.
  • An optional secondary decimal number separator (requires a custom branch of Parlot ).
  • Raw strings which are not parsed for escape sequences.
  • C-Style octal literals.
  • Result Reference character. A pseudo-function that would let a user application return some value, such as the result of a previous calculation. This is handy when an expression should include this result multiple times.
  • Percent calculations.
  • Factorials (both regular and any complex factorials on integers are supported).
  • Logical XOR operations.
  • Certain Unicode characters can be used as operators.
  • Lowercase lookup for parameter and function names.
  • Optional non-recursive evaluator for large and complex expressions.
  • The possibility to re-initialize the parser before parsing an expression.
  • New flags in ExpressionOptions to skip date and GUID parsers in order to speed up parsing.
  • Minor improvements in the asyncrhonous code (CancellationToken and ConfigureAwait(false) are present in all calls).
  • The main projects have been combined into one project.

This version attempts to be synchronized with the main NCalc project, which resides here on github.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.5.0.1 35 9/12/2025
8.5.0 175 8/30/2025
8.1.0 130 8/20/2025
8.0.2 111 8/16/2025
8.0.1 134 8/14/2025
8.0.0 131 8/12/2025
7.0.1 174 7/27/2025
7.0.0 159 7/15/2025
5.6.0-beta 136 7/6/2025
5.6.0-alpha 138 7/3/2025