Soenneker.Extensions.Decimal 4.0.628

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.Decimal --version 4.0.628
                    
NuGet\Install-Package Soenneker.Extensions.Decimal -Version 4.0.628
                    
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="Soenneker.Extensions.Decimal" Version="4.0.628" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.Decimal" Version="4.0.628" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.Decimal" />
                    
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 Soenneker.Extensions.Decimal --version 4.0.628
                    
#r "nuget: Soenneker.Extensions.Decimal, 4.0.628"
                    
#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 Soenneker.Extensions.Decimal@4.0.628
                    
#: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=Soenneker.Extensions.Decimal&version=4.0.628
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.Decimal&version=4.0.628
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.Decimal

Formatting, rounding, conversion, and zero-safe division extensions for decimal.

Installation

dotnet add package Soenneker.Extensions.Decimal

Currency

using Soenneker.Extensions.Decimal;

string display = 1234.567m.ToCurrencyDisplay();      // "$1,234.57"
string whole = 1234.5m.ToCurrencyDisplay(true);      // "$1,234"
decimal amount = 12.345m.ToCurrency();               // 12.34m
decimal wholeAmount = 12.5m.ToCurrency(false);       // 12m

decimal? missing = null;
string? missingDisplay = missing.ToCurrencyDisplay(); // null

ToCurrencyDisplay() deliberately produces US-style display text: $, comma grouping, a dot decimal separator, and a leading minus sign for negative values. It does not use the current culture. Both currency methods use MidpointRounding.ToEven; the Boolean parameters differ: excludePlaces controls display, while includePlaces controls the decimal result.

Percent display

ToPercentDisplay() treats the input as a fraction, multiplies it by 100, keeps up to two decimal places, and appends %.

0.25m.ToPercentDisplay();   // "25%"
0.3333m.ToPercentDisplay(); // "33.33%"

The numeric portion uses the current culture's decimal separator. Very large values can overflow when scaled by 100.

Rounding and conversion

decimal rounded = 2.345m.ToRounded(2); // 2.34m; midpoint-to-even
decimal? optional = ((decimal?)null).ToRounded(2); // null
int integer = 2.5m.ToInt();             // 2; midpoint-to-even
double approximate = 1.1m.ToDouble();

ToRounded() accepts 0 through 28 fractional digits. ToInt() throws when the rounded value is outside the Int32 range. Decimal-to-double conversion can lose precision.

Zero-safe division

decimal ratio = 10m.SafeDivision(4m); // 2.5m
decimal zero = 10m.SafeDivision(0m);  // 0m

Use SafeDivision() only when a zero denominator should intentionally produce zero; it can otherwise hide invalid input.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Soenneker.Extensions.Decimal:

Package Downloads
Soenneker.Extensions.Float

A collection of useful floating point extension methods

Soenneker.Utils.Math

Some useful math related utility methods

Soenneker.Stripe.Extensions.Decimals

Estimates card and ACH fees, net proceeds, gross-up amounts, and fee breakdowns using configurable package assumptions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.640 309 11/18/2026
11.0.639 340 11/11/2026
11.0.638 167 11/10/2026
11.0.637 598 10/26/2026
4.0.636 871 10/14/2026
4.0.635 175 10/14/2026
4.0.630 200 10/12/2026
4.0.629 153 10/12/2026
4.0.628 207 10/11/2026
4.0.627 616 9/24/2026
4.0.626 477 9/15/2026
4.0.625 272 9/12/2026
4.0.624 420 8/30/2026
4.0.623 208 8/29/2026
4.0.622 966 7/27/2026
4.0.621 498 7/16/2026
4.0.620 1,146 6/18/2026
4.0.619 696 6/5/2026
4.0.617 1,351 3/12/2026
4.0.616 192 3/12/2026
Loading failed

Fix release metadata shell injection