Skip to content

Module_Numerics

cyclone_dll edited this page Jul 6, 2026 · 8 revisions

Location: Home / Numerics module

Numerics module

This module provides multiple types related to numerical computation, including integers, floating-point numbers, complex numbers, rational numbers, fractions, and more. These types offer high-precision numerical computation and can be converted to and from other numeric types.

All types below are located in namespace: Vorcyc.Mathematics.Numerics


📒Contents


1. Vorcyc.Mathematics.Numerics.BigFloat struct

A struct representing a high-precision floating-point number.

Features:

  • Represents high-precision floating-point numbers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports conversion to and from other numeric types
  • Supports advanced math operations such as square root and exponentiation
  • Fields: DataBits, Scale, Size, Exponent, IsZero, OutOfPrecision, IsPositive, IsNegative, Sign, Int
  • Properties: GetPrecision (read-only), GetAccuracy (read-only)
  • Methods: Floor (instance), Ceiling (instance), Sqrt (static), Pow (static), Parse (static), TryParse (static)
  • Operator overloads: +, -, *, /
  • Interface implementations: IComparable, IComparable<BigFloat>, IEquatable<BigFloat>

Usage example:

BigFloat a = new BigFloat(123.456);
BigFloat b = new BigFloat("789.012");
BigFloat resultAdd = a + b;
BigFloat resultSub = a - b;
BigFloat resultMul = a * b;
BigFloat resultDiv = a / b;
BigFloat resultSqrt = BigFloat.Sqrt(a);
BigFloat resultPow = BigFloat.Pow(a, 2);

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");
Console.WriteLine($"Sqrt: {resultSqrt}");
Console.WriteLine($"Pow: {resultPow}");

2. Vorcyc.Mathematics.Numerics.Complex<T> struct

A struct representing a complex number with a generic numeric type.

Features:

  • Represents complex numbers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports polar coordinate conversion
  • Supports magnitude, conjugate, and related operations
  • Fields: Real, Imaginary
  • Properties: Magnitude, Phase
  • Methods: Add, Subtract, Multiply, Divide, Negate, Conjugate, Reciprocal, Abs, Sqrt, Pow, Log, Exp, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh
  • Operator overloads: +, -, *, /, ==, !=
  • Interface implementations: IEquatable<Complex<T>>, IFormattable, INumberBase<Complex<T>>, ISignedNumber<Complex<T>>

Usage example:

Complex<double> c1 = new Complex<double>(1.0, 2.0);
Complex<double> c2 = new Complex<double>(3.0, 4.0);
Complex<double> resultAdd = c1 + c2;
Complex<double> resultSub = c1 - c2;
Complex<double> resultMul = c1 * c2;
Complex<double> resultDiv = c1 / c2;
double magnitude = Complex<double>.Abs(c1);
Complex<double> conjugate = Complex<double>.Conjugate(c1);

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");
Console.WriteLine($"Magnitude: {magnitude}");
Console.WriteLine($"Conjugate: {conjugate}");

3. Vorcyc.Mathematics.Numerics.ComplexFp32 struct

A struct representing a complex number with single-precision floating-point components.

Features:

  • Represents complex numbers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports polar coordinate conversion
  • Supports magnitude, conjugate, and related operations
  • Fields: Real, Imaginary
  • Properties: Magnitude, Phase
  • Methods: Add, Subtract, Multiply, Divide, Negate, Conjugate, Reciprocal, Abs, Sqrt, Pow, Log, Exp, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh
  • Operator overloads: +, -, *, /, ==, !=
  • Interface implementations: IEquatable<ComplexFp32>, IFormattable, INumberBase<ComplexFp32>, ISignedNumber<ComplexFp32>

Usage example:

ComplexFp32 c1 = new ComplexFp32(1.0f, 2.0f);
ComplexFp32 c2 = new ComplexFp32(3.0f, 4.0f);
ComplexFp32 resultAdd = c1 + c2;
ComplexFp32 resultSub = c1 - c2;
ComplexFp32 resultMul = c1 * c2;
ComplexFp32 resultDiv = c1 / c2;
float magnitude = ComplexFp32.Abs(c1);
ComplexFp32 conjugate = ComplexFp32.Conjugate(c1);

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");
Console.WriteLine($"Magnitude: {magnitude}");
Console.WriteLine($"Conjugate: {conjugate}");

4. Vorcyc.Mathematics.Numerics.Int24 struct

A struct representing a 24-bit signed integer.

Features:

  • Represents 24-bit signed integers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports conversion to and from other numeric types
  • Operator overloads: +, -, *, /
  • Interface implementations: IMinMaxValue<Int24>, IAdditionOperators<Int24, Int24, Int24>, ISubtractionOperators<Int24, Int24, Int24>, IMultiplyOperators<Int24, Int24, Int24>, IDivisionOperators<Int24, Int24, Int24>, IAdditiveIdentity<Int24, Int24>, IComparable, IComparable<Int24>, IFormattable

Usage example:

Int24 a = new Int24(123456);
Int24 b = new Int24(654321);
Int24 resultAdd = a + b;
Int24 resultSub = a - b;
Int24 resultMul = a * b;
Int24 resultDiv = a / b;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");

5. Vorcyc.Mathematics.Numerics.IntRange struct

A struct representing an integer range.

Features:

  • Represents an integer range
  • Checks whether a value is within the range
  • Computes the intersection of ranges
  • Properties: Min, Max, Length
  • Methods: IsInside, Intersection, IsOverlapping, ToString
  • Operator overloads: ==, !=
  • Interface implementations: IEquatable<IntRange>, IEnumerable<int>

Usage example:

IntRange range = new IntRange(1, 10);
bool isInside = range.IsInside(5);
IntRange intersection = range.Intersection(new IntRange(5, 15));

Console.WriteLine($"IsInside: {isInside}");
Console.WriteLine($"Intersection: [{intersection.Min}, {intersection.Max}]");

6. Vorcyc.Mathematics.Numerics.Number class

A class representing a number as a digit list with arbitrary precision.

Features:

  • Represents arbitrary-precision numbers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports conversion to and from other numeric types
  • Properties: DigitsCount, IntegerDigitsCount, FloatingDigitsCount, FirstDigit, LastDigit
  • Methods: Abs, Round, Floor, Ceiling, GetFloatingPart, AppendFirstDigit, RemoveFirstDigit, AppendLastDigit, RemoveLastDigit
  • Operator overloads: +, -, *, /
  • Interface implementations: IComparable<Number>

Usage example:

Number n1 = new Number("12345678901234567890");
Number n2 = new Number("98765432109876543210");
Number resultAdd = n1 + n2;
Number resultSub = n1 - n2;
Number resultMul = n1 * n2;
Number resultDiv = n1 / n2;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");

7. Vorcyc.Mathematics.Numerics.Point<T> struct

A struct representing a point on a 2D plane with a generic numeric type.

Features:

  • Represents a point on a 2D plane
  • Supports addition and subtraction
  • Supports distance calculation
  • Properties: X, Y, IsEmpty
  • Methods: Add, Subtract, ToString
  • Operator overloads: +, - (with Size<T>, (T width, T height) tuple, or scalar T; no Point<T> ± Point<T>)
  • Interface implementations: IAdditionOperators<Point<T>, Size<T>, Point<T>>, ISubtractionOperators<Point<T>, Size<T>, Point<T>>, IEquatable<Point<T>>

Usage example:

Point<int> p = new Point<int>(1, 2);
Size<int> s = new Size<int>(3, 4);
Point<int> resultAdd = p + s;
Point<int> resultSub = p - s;

Point<float> pf1 = new Point<float>(1.0f, 2.0f);
Point<float> pf2 = new Point<float>(3.0f, 4.0f);
float distance = Point<float>.Distance(pf1, pf2);

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Distance: {distance}");

8. Vorcyc.Mathematics.Numerics.PointFp32 struct

A struct representing a point on a 2D plane with single-precision floating-point coordinates.

Features:

  • Represents a point on a 2D plane
  • Supports addition and subtraction
  • Properties: X, Y, IsEmpty
  • Methods: Add, Subtract, ToString
  • Operator overloads: +, -, ==, !=

Usage example:

PointFp32 p = new PointFp32(1.0f, 2.0f);
SizeFp32 s = new SizeFp32(3.0f, 4.0f);
PointFp32 resultAdd = p + s;
PointFp32 resultSub = p - s;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");

9. Vorcyc.Mathematics.Numerics.Range<T> class

A class representing a value range with a generic numeric type.

Features:

  • Represents a value range
  • Checks whether a value is within the range
  • Computes intersection and union of ranges
  • Properties: Value, Minimum, Maximum
  • Methods: IsInside, Intersection (returns null when the ranges do not overlap), Union, IsOverlapping, ToString
  • Interface implementations: IEquatable<Range<T>>

Usage example:

Range<int> range = new Range<int>(1, 10);
bool isInside = range.IsInside(5);
Range<int> intersection = range.Intersection(new Range<int>(5, 15));
Range<int> union = range.Union(new Range<int>(5, 15));

Console.WriteLine($"IsInside: {isInside}");
Console.WriteLine($"Intersection: [{intersection.Minimum}, {intersection.Maximum}]");
Console.WriteLine($"Union: [{union.Minimum}, {union.Maximum}]");

10. Vorcyc.Mathematics.Numerics.Rational<T> struct

A struct representing a rational number with a generic integer type.

Features:

  • Represents rational numbers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports conversion to and from other numeric types
  • Fields: Numerator, Denominator
  • Operators: +, -, *, /
  • Methods: Negate, Reciprocal, Abs, ToDouble, ToFloatingPointNumber<TFloatingNumber>()
  • Interface implementations: IComparable<Rational<T>>, IEquatable<Rational<T>>

Usage example:

Rational<int> r1 = new Rational<int>(1, 2);
Rational<int> r2 = new Rational<int>(3, 4);
Rational<int> resultAdd = r1 + r2;
Rational<int> resultSub = r1 - r2;
Rational<int> resultMul = r1 * r2;
Rational<int> resultDiv = r1 / r2;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");

11. Vorcyc.Mathematics.Numerics.RectangleFP32 struct

A struct representing a rectangle with floating-point coordinates and dimensions.

Features:

  • Represents a rectangle
  • Checks whether a point is inside the rectangle
  • Computes intersection and union of rectangles
  • Properties: X, Y, Width, Height, Location, Size, IsEmpty, Left, Right, Top, Bottom
  • Methods: Contains, Inflate, Intersect, IntersectsWith, Offset, ToString
  • Operator overloads: ==, !=

Usage example:

RectangleFP32 rect = new RectangleFP32(0.0f, 0.0f, 10.0f, 20.0f);
bool contains = rect.Contains(5.0f, 5.0f);
RectangleFP32 intersection = RectangleFP32.Intersect(rect, new RectangleFP32(5.0f, 5.0f, 10.0f, 20.0f));
RectangleFP32 union = RectangleFP32.Union(rect, new RectangleFP32(5.0f, 5.0f, 10.0f, 20.0f));

Console.WriteLine($"Contains: {contains}");
Console.WriteLine($"Intersection: {intersection}");
Console.WriteLine($"Union: {union}");

12. Vorcyc.Mathematics.Numerics.Size<T> struct

A struct representing a 2D size with a generic numeric type.

Features:

  • Represents a 2D size
  • Supports addition, subtraction, multiplication, division, and related operations
  • Properties: Width, Height
  • Methods: ToString
  • Operator overloads: +, -, *, / (each with a scalar T; no Size<T> ± Size<T>)

Usage example:

Size<int> size = new Size<int>(10, 20);
Size<int> resultAdd = size + 2;
Size<int> resultSub = size - 2;
Size<int> resultMul = size * 2;
Size<int> resultDiv = size / 2;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");

13. Vorcyc.Mathematics.Numerics.SizeFp32 struct

A struct representing a 2D size with single-precision floating-point dimensions.

Features:

  • Represents a 2D size
  • Supports addition, subtraction, multiplication, division, and related operations
  • Properties: Width, Height, IsEmpty
  • Methods: Add, Subtract, ToString
  • Operator overloads: +, -, ==, !=

Usage example:

SizeFp32 size1 = new SizeFp32(10.0f, 20.0f);
SizeFp32 size2 = new SizeFp32(5.0f, 5.0f);
SizeFp32 resultAdd = size1 + size2;
SizeFp32 resultSub = size1 - size2;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");

14. Vorcyc.Mathematics.Numerics.UInt24 struct

A struct representing a 24-bit unsigned integer.

Features:

  • Represents 24-bit unsigned integers
  • Supports addition, subtraction, multiplication, division, and related operations
  • Supports conversion to and from other numeric types
  • Operator overloads: +, -, *, /
  • Interface implementations: IMinMaxValue<UInt24>, IAdditionOperators<UInt24, UInt24, UInt24>, ISubtractionOperators<UInt24, UInt24, UInt24>, IMultiplyOperators<UInt24, UInt24, UInt24>, IDivisionOperators<UInt24, UInt24, UInt24>, IAdditiveIdentity<UInt24, UInt24>

Usage example:

UInt24 a = new UInt24(123456);
UInt24 b = new UInt24(654321);
UInt24 resultAdd = a + b;
UInt24 resultSub = a - b;
UInt24 resultMul = a * b;
UInt24 resultDiv = a / b;

Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");

Language / 语言: English · 简体中文


Home


首页

Clone this wiki locally