This text originates from GitHub - GenericMath.
Provides a way to perform generic math functions on the following numeric types:
ushort. The following operations are supported: add, subtract, multiply, divide, modulo, negate, plus, increment, decrement, leftShift, rightShift, onesComplement, and, or, xor.
Check out CodeChops projects for more projects.
- Supports converting at runtime (when the type to convert to/from is not known at compile time).
- Contains a JSON converter which cleanly and correctly converts these numbers from and to JSON.
- This functionality can nowadays also be achieved by using the GenericMath functionality of .NET 7. C# 11 also has to be used because it makes use of static abstract members in interfaces, which is introduced in C# 11. See: Microsoft - Generic math
- This code is adapted from: StackExchange - Generic Calculator and Generic Number