Prahelika.Calculators
1.4.0
dotnet add package Prahelika.Calculators --version 1.4.0
NuGet\Install-Package Prahelika.Calculators -Version 1.4.0
<PackageReference Include="Prahelika.Calculators" Version="1.4.0" />
<PackageVersion Include="Prahelika.Calculators" Version="1.4.0" />
<PackageReference Include="Prahelika.Calculators" />
paket add Prahelika.Calculators --version 1.4.0
#r "nuget: Prahelika.Calculators, 1.4.0"
#:package Prahelika.Calculators@1.4.0
#addin nuget:?package=Prahelika.Calculators&version=1.4.0
#tool nuget:?package=Prahelika.Calculators&version=1.4.0
Prahelika.Calculators
A small, well-tested .NET library with basic, scientific, finance and India-focused calculators (FD, RD, PPF, GST split, income tax), loan planning tools, and statistics, unit conversion, date and programmer calculators. Calculations never throw for bad user input: they return a result object that says what went wrong.
Install
dotnet add package Prahelika.Calculators
Quick start
Basic (exact decimal arithmetic)
using Prahelika.Calculators.Core.Basic;
var calculator = new BasicCalculator();
var result = calculator.Divide(10m, 4m);
if (result.IsSuccess)
{
Console.WriteLine(result.Value); // 2.5
}
else
{
Console.WriteLine(result.Message); // for example, a division by zero message
}
Scientific (double arithmetic, degrees or radians)
The angle unit is chosen when you create the calculator. Radians is the default.
using Prahelika.Calculators.Core.Scientific;
var radians = new ScientificCalculator();
var degrees = new ScientificCalculator(AngleUnit.Degrees);
Console.WriteLine(radians.SquareRoot(16).Value); // 4
Console.WriteLine(degrees.Sin(30).Value); // about 0.5
Functions: power, square root, nth root, natural log, log10, log in any base, sin, cos, tan, asin, acos, atan and factorial.
Finance (decimal, rounded to 2 places by default)
Rates are percentages per year, so 12 means 12%.
using Prahelika.Calculators.Core.Finance;
var finance = new FinanceCalculator();
// Loan of 100,000 at 12% a year for 12 months
var emi = finance.Emi(100000m, 12m, 12);
if (emi.IsSuccess)
{
Console.WriteLine(emi.Value.MonthlyPayment); // 8884.88
}
Also available: simple and compound interest, loan amortisation schedule, SIP future value, return on investment and GST (added or taken out).
India finance: FD, RD, PPF, GST split and income tax
using Prahelika.Calculators.Core.Finance;
// Fixed deposit: 1,00,000 at 7% for 12 months, interest added every quarter
var fd = new SavingsCalculator().FixedDeposit(100000m, 7m, 12);
Console.WriteLine(fd.Value!.MaturityAmount); // 107185.90
// GST of 18% on 1000, split into CGST and SGST
var split = new GstSplitCalculator().GstSplit(1000m, 18m);
Console.WriteLine(split.Value!.Cgst); // 90 (and SGST is 90)
// Income-tax estimate, new regime, salaried, 15 lakh a year
var tax = new IncomeTaxCalculator().EstimateNewRegime(1500000m);
Console.WriteLine(tax.Value!.TotalTax); // 97500
Also available: recurring deposit (RecurringDeposit) and PPF (Ppf). The income-tax slabs for FY 2026-27 live in one IncomeTaxRules table, so they can be updated or replaced. The estimate does not include surcharge. Check incometax.gov.in for the latest rules.
Loan planning: prepayment, comparing loans, how much can I borrow
using Prahelika.Calculators.Core.Finance;
var planner = new LoanPlanner();
// 1,00,000 at 12% for 12 months. After the 6th EMI, pay 20,000 extra.
var prepay = planner.Prepay(100000m, 12m, 12, prepaymentMonth: 6, prepaymentAmount: 20000m);
Console.WriteLine(prepay.Value!.NewMonths); // 10
Console.WriteLine(prepay.Value!.InterestSaved); // 1075.12
// Two offers side by side, including the processing fee
var comparison = planner.CompareLoans(
new LoanOffer(1000000m, 9m, 240, ProcessingFee: 5000m),
new LoanOffer(1000000m, 9.2m, 240));
Console.WriteLine(comparison.Value!.Cheaper); // First, Second or Same
// "I can pay 20,000 a month. How much can I borrow?" (9% for 20 years)
var borrow = planner.MaxLoanAmount(20000m, 9m, 240);
Console.WriteLine(borrow.Value!.MaxLoanAmount); // 2222899.08
Prepay assumes the same EMI continues after the lump sum, so the loan ends sooner. MaxLoanAmount rounds down, so the EMI never goes above your monthly payment.
Statistics, units, dates and programmer tools
using Prahelika.Calculators.Core.Dates;
using Prahelika.Calculators.Core.Programmer;
using Prahelika.Calculators.Core.Statistics;
using Prahelika.Calculators.Core.Units;
// Statistics: mean, median, mode and standard deviation
var stats = new StatisticsCalculator().Summarise(new[] { 2m, 4m, 4m, 4m, 5m, 5m, 7m, 9m });
Console.WriteLine(stats.Value!.Mean); // 5
Console.WriteLine(stats.Value!.Median); // 4.5
Console.WriteLine(stats.Value!.PopulationStandardDeviation); // 2
Console.WriteLine(stats.Value!.SampleStandardDeviation); // 2.14
// Units: length, weight, temperature, area and volume
var converter = new UnitConverter();
Console.WriteLine(converter.Convert(1m, MeasurementUnit.Mile, MeasurementUnit.Kilometre).Value); // 1.609344
Console.WriteLine(converter.Convert(100m, MeasurementUnit.Celsius, MeasurementUnit.Fahrenheit).Value); // 212
// Dates: age in years, months and days. You pass the date to measure to, so results never depend on the clock.
var age = new DateCalculator().Age(new DateOnly(2000, 1, 15), new DateOnly(2026, 11, 27));
Console.WriteLine($"{age.Value!.Years} years, {age.Value.Months} months, {age.Value.Days} days"); // 26 years, 10 months, 12 days
// Programmer: number bases and bitwise operations on 64-bit numbers
var programmer = new ProgrammerCalculator();
Console.WriteLine(programmer.ConvertBase("255", NumberBase.Decimal).Value!.Hexadecimal); // FF
Console.WriteLine(programmer.Bitwise(12, BitwiseOperation.And, 10).Value!.Value); // 8
Also available: AddMonths and AddDays on DateCalculator, and Between for the gap between two dates. Adding a month to 31 January gives the last day of February. In binary, octal and hexadecimal, a negative number is shown as its 64 bits (two's complement).
Handling errors
Every calculation returns a CalcResult<T>:
| Member | Meaning |
|---|---|
IsSuccess |
true when the calculation worked |
Value |
The answer (only when successful) |
Error |
DivisionByZero, InvalidInput, Overflow, or None |
Message |
A readable explanation of the error |
Only mistakes in your own code, such as an invalid number of decimal places in a constructor, throw exceptions.
Links
- Live demo and live API with Swagger
- Source code
- Changelog
- Licence: MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- No dependencies.
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 |
|---|---|---|
| 1.4.0 | 63 | 11/30/2026 |
| 1.3.0 | 64 | 11/28/2026 |
| 1.2.0 | 65 | 11/27/2026 |
| 1.1.0 | 96 | 11/23/2026 |
| 1.0.0 | 93 | 11/16/2026 |
| 0.3.1-alpha | 94 | 11/16/2026 |
| 0.0.1-alpha | 87 | 11/12/2026 |