Table of Contents

Class NumericRangeTools

Namespace
Plugin.BaseTypeExtensions
Assembly
Plugin.BaseTypeExtensions.dll

Provides utility methods for numeric range conversions, percentage calculations, and value mapping operations.

public static class NumericRangeTools
Inheritance
NumericRangeTools
Inherited Members

Remarks

This class contains helper methods for converting between absolute and relative values, percentage calculations, and generating numeric ranges. All methods are optimized for performance and support generic numeric types where applicable.

Methods

GetRange(DateTime, DateTime, TimeSpan)

Generates a sequence of DateTime values from start to end with a specified step.

public static IEnumerable<DateTime> GetRange(DateTime start, DateTime end, TimeSpan step)

Parameters

start DateTime

The start of the range.

end DateTime

The end of the range.

step TimeSpan

The step size between each DateTime in the range.

Returns

IEnumerable<DateTime>

An IEnumerable of DateTime values representing the range.

Remarks

This method generates a sequence of DateTime values starting from start and stopping before end, using the magnitude of step to move between values. If step is zero or equals MinValue, an empty sequence is returned.

GetRange(double, double, double)

Generates a sequence of numbers from start to end with a specified step.

public static IEnumerable<double> GetRange(double start, double end, double step)

Parameters

start double

The start of the range.

end double

The end of the range.

step double

The step size between each number in the range.

Returns

IEnumerable<double>

An IEnumerable of double values representing the range.

Remarks

This method generates a sequence of numbers starting from start and stopping before end, using the magnitude of step to move between values. If step is zero, NaN, or infinite, an empty sequence is returned.

GetRange(float, float, float)

Generates a sequence of floating-point numbers from start to end with a specified step.

public static IEnumerable<float> GetRange(float start, float end, float step)

Parameters

start float

The start of the range.

end float

The end of the range.

step float

The step size between each number in the range.

Returns

IEnumerable<float>

An IEnumerable of float values representing the range.

Remarks

This method generates a sequence of floating-point numbers starting from start and stopping before end, using the magnitude of step to move between values. If step is zero, NaN, or infinite, an empty sequence is returned.

GetRange<T>(T, T, T)

Generates a sequence of numbers from start to end with a specified step.

public static IEnumerable<T> GetRange<T>(T start, T end, T step) where T : INumber<T>

Parameters

start T

The start of the range.

end T

The end of the range.

step T

The step size between each number in the range.

Returns

IEnumerable<T>

An IEnumerable of T values representing the range.

Type Parameters

T

The numeric type that implements INumber<T>.

Remarks

This method generates a sequence of numbers starting from start to end, inclusive, with the specified step. If step is zero, an empty sequence is returned. The sequence will include both start and end if they are reachable with the given step.