TypedMath 1.0.10
dotnet add package TypedMath --version 1.0.10
NuGet\Install-Package TypedMath -Version 1.0.10
<PackageReference Include="TypedMath" Version="1.0.10" />
paket add TypedMath --version 1.0.10
#r "nuget: TypedMath, 1.0.10"
// Install TypedMath as a Cake Addin #addin nuget:?package=TypedMath&version=1.0.10 // Install TypedMath as a Cake Tool #tool nuget:?package=TypedMath&version=1.0.10
Typed Math
Sometimes when working with calculations I tend to get a touch of Dyscalculia. That is why I loved Visual Basic in the 90s. It had descriptive code, and VB.net does still have it. But I prefer to work with C#. Though I do miss some functions from time to time. To avoid visits from the ghost of Dyscalculia I created this project. At first it seemed like a pretty meaningless project, but soon I realised this could be useful. So, I made it a NuGet. It's all extensions to number types.
LinQ is great and it does offer a lot of ways to make the code more readable, if you use LinQ I see no reason why you should need this package.
Instead of writing
var x = 10 * 32 + y;
you can write
var x = 10.MultipliedWith(32).Add(y);
The package contains namespaces for the most common data types in Visual Studio.
To use the extensions, use any of the namespaces
using MarcusMedinaPro.TypedMath.ByteExtension; // Bytes
using MarcusMedinaPro.TypedMath.CharExtension; // Char
using MarcusMedinaPro.TypedMath.DecimalExtension; // Decimal
using MarcusMedinaPro.TypedMath.DoubleExtension; // Double
using MarcusMedinaPro.TypedMath.IntExtension; // Int
using MarcusMedinaPro.TypedMath.LongExtension; // Long
using MarcusMedinaPro.TypedMath.SByteExtension; // SByte
using MarcusMedinaPro.TypedMath.ShortExtension; // Short
using MarcusMedinaPro.TypedMath.UintExtension; // Uint
using MarcusMedinaPro.TypedMath.UlongExtension; //Ulong
using MarcusMedinaPro.TypedMath.UshorttExtension; //Ushort
Most of the functions have automatic casting from one to another, so you can work with mixed doubles and floats and ints if you want.
Disclaimer
This project is nothing magical most of the functions are one-liners. The idea is not to create special functions, but to make the code easier to read. If you're a hardcore coder that love to minimize your code, this is not for you. But if you feel like you want code that will be easy to read, this might help.
Changes
- 10190603 - Added array handlers
- 20190524 - Added Percent, Highest, Lowest, Swap
- 20190526 - Renamed ChoseHighestValue/ChoseLowestValue to ChoseHighestValueOf/ChoseLowestValueOf. Added SetHighestValueOf/SetLowestValueOf. Swap uses reference now
- 20190529 - Corrected misspelling in Subtract and added Obsolete tag to the misspelled method. Renamed ChoseHighest/Lowest to ChooseIfHigher/ChooseIfLower
Source code
You can find the code at https://github.com/MarcusMedina/TypedMath
NuGet
The NuGet is available at https://www.nuget.org/packages/TypedMath/
Collaboration
Feel free to add, suggest or request a feature. If you want to help develop this NuGet, feel free to send a Pull Request.
Borrowed code
- LinQ Prime numbers, Zoran Horvat: http://www.codinghelmet.com/articles/linq-all-primes/
- Increase/Decrease array values, mgp (https://stackoverflow.com/users/55943/mqp ) @ https://stackoverflow.com/a/823537
Borrowed Icons
- The icon is GPL from http://www.iconarchive.com/show/ios7-icons-by-icons8/Science-Math-icon.html.
Cheers. Marcus
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has 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.
First release