IsEven 2.0.0
See the version list below for details.
dotnet add package IsEven --version 2.0.0
NuGet\Install-Package IsEven -Version 2.0.0
<PackageReference Include="IsEven" Version="2.0.0" />
paket add IsEven --version 2.0.0
#r "nuget: IsEven, 2.0.0"
// Install IsEven as a Cake Addin #addin nuget:?package=IsEven&version=2.0.0 // Install IsEven as a Cake Tool #tool nuget:?package=IsEven&version=2.0.0
IsEven
A robust, extensible, and blue-sky-thinking .NET library for calculating if an integer is even.
In a rapidly-changing technology landscape where the demystification of number even-ness is mission-critical, this may be the game-changer for facing into your organisational arithmetic delivery.
Examples
Use the IsEvenCalculator to determine the even-ness of your number, using Modulo division by default:
bool isEven = IsEvenCalculator.IsEven(2);
bool isOdd = IsEvenCalculator.IsOdd(5);
Or use one of the extension methods:
bool isEven = 2.IsEven();
bool isOdd = 5.IsOdd();
An 'AlgorithmType' argument may optionally be supplied to specify the algorithm to use when calculating whether a number is even:
bool isEven = 2.IsEven(AlgorithmType.LastDigitCheck);
Sometimes you may be unsure if you have a number that is odd or even - the below will alleviate all doubt:
bool isOddOrEven = 2.IsOddOrEven();
bool isOddOrEven = IsEvenCalculator.IsOddOrEven(2);
Abstraction Layers
Take the standard Modulo division algorithm to calculate if a number is even:
return n % 2 == 0;
This is:
- Far too easy to read
- Overly maintainable
- The top answer on StackOverflow
Allowing needlessly supportable logic such as this to run amock in your enterprise codebase would be a foolish endeavour, thus multiple abstracted layers have been added to this library to support possible future requirements.
These layers include:
- Optional algorithm types being specified which may be slower, such as checking the last digit of the number, using Math.DivRem, or bit-shifting, as examples
- Extensibility of the name of numbers, in case they are fundamentally changed in future
- Abstraction of whether 0 should be considered even or not, to avoid any arguments
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 was computed. 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. |
-
net6.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.