FloatingPointExtensionMethods
Extension methods for System.Double
Methods
Create an array from this number to another.
Returns: Array from a to b.
Create an array of doubles from a value to a limit.
Returns: Array.
Create an array from this number to another.
Returns: Array from a to b.
Compute the mean (average) of a collection of numbers. This method is designed to work with many numbers as well as very large numbers. Essentially, if you're certain that the sum of all values doesn't exceed 1e128, there are faster ways to compute the average.
Returns: Average of all numbers.
Compute the mean (average) of a collection of numbers. This method is designed to work with many numbers as well as very large numbers. Essentially, if you're certain that the sum of all values doesn't exceed 1e128, there are faster ways to compute the average.
Returns: Average of all numbers.
Limit a number to a range.
Returns: Clipped number.
Limit a number to a range.
Returns: Clipped number.
Limit a number to a range.
Returns: Clipped number.
Limit a number to a range.
Returns: Clipped number.
Limit a number to a range.
Returns: Clipped number.
Limit a number to a range.
Returns: Clipped number.
Gets the number of significant decimal places of a decimal number.
Returns: Number of decimal places.
Create an enumeration from one value to another.
public static IEnumerable<double> EnumerateTo()
this double
number0,
First number in enumeration.
number1,
Inclusive last number in enumeration.
steps
Number of steps. Enumeration will contain steps+1 elements.
Returns: Enumeration from a to b.
Format a double using a limited number of decimal places, appending an ellipsis whenever the displayed digits do not capture the exact value. The displayed digits are rounded, so 5.99999999993 formats as "6.0…" rather than "5.99999…".
Format a bigInteger value using scientific base-10 notation.
public static string FormatScientific()
this BigInteger
value,
Value to format.
minimumDigits,
Minimum number of digits to use in the decimal.
maximumDigits,
Maximum number of digits to use in the decimal.
superscript
True if superscript exponents ought to be used.
Returns: Scientific format.
Format a double value using scientific base-10 notation.
Returns: Scientific format.
Return the fractional portion of a double. This method does not suffer from the same rounding issues as f = x % 1 or f = x - floor(x). For example try taking an arithmetical approach to finding the fractional part of 100000000000000.1 and you'll get 0.09375 instead of 0.1
Returns: Fractional part between -1 and +1. Negative input values yield negative fractional parts.
Gets both the magnitude of a number and the scaled value.
Gets both the magnitude of a number.
Gets the highest number in an array.
Returns: Highest number in the set.
Gets the highest number in an array.
Returns: Highest number in the set.
Return the integral portion of a double. This is equivalent to Math.Truncate().
Returns: Integral part. Negative input values yield negative parts that are either equal to or larger than the input.
Gets whether the number is in between both limits. This method returns true even if the number is coincident with the limits.
Gets whether the number is in between both limits. This method returns true even if the number is coincident with the limits.
Gets whether a double precision value is an exact integer in the 32-bit range.
Returns: True if number is expressible as a 32-bit integer without loss of information.
Gets whether a double precision value is an exact integer in the 64-bit range.
Returns: True if number is expressible as a 64-bit integer without loss of information.
Gets the lowest number in an array.
Returns: Lowest number in the set.
Gets the lowest number in an array.
Returns: Lowest number in the set.
Map a value from one numeric domain to another.
Returns: Mapped value.
Map a normalised value to a new numeric domain.
Returns: Mapped value.
Map a value from one numeric domain to another.
Returns: Mapped value.
Map a normalised value to a new numeric domain.
Returns: Mapped value.
Compute the median of a collection of numbers. This method uses the QuickMedian algorithm.
Returns: Median of values.
Compute the median of a collection of numbers. This method uses the QuickMedian algorithm.
Returns: Median of values.
Gets the first double value that is larger than the current one.
Returns: Next double value.
Gets the first double value that is larger than the current one.
Returns: Next double value.
Gets the distance from this number to the next possible number.
Returns: Epsilon to next value.
Gets the order of magnitude bigger than or equal to the given number. The value returned is equal to or bigger than number, where "bigger" means further away from zero. Ie. negative values will result in larger negative values.
Returns: Order of magnitude.
Gets the order of magnitude bigger than or equal to the given number. The value returned is equal to or bigger than number, where "bigger" means further away from zero. Ie. negative values will result in larger negative values.
Returns: Order of magnitude.
Gets the order of magnitude bigger than or equal to the given number. The value returned is equal to or bigger than number, where "bigger" means further away from zero. Ie. negative values will result in larger negative values.
Returns: Order of magnitude.
Gets the order of magnitude bigger than or equal to the given number. The value returned is equal to or bigger than number, where "bigger" means further away from zero. Ie. negative values will result in larger negative values.
Returns: Order of magnitude.
Gets the number of steps between two values. This is one more than the amount of unique numbers in between a and b.
Returns: Number of steps between values.
Gets the first double value that is smaller than the current one.
Returns: Previous double value.
Gets the first double value that is smaller than the current one.
Returns: PRevious double value.
Gets the distance from this number to the previous possible number.
Returns: Epsilon to prev value.
Gets the order of magnitude smaller than or equal to the given number. The value returned is equal to or smaller than number, where "smaller" means closer to zero. Ie. negative values will result in smaller negative values.
Returns: Order of magnitude.
Gets the order of magnitude smaller than or equal to the given number. The value returned is equal to or smaller than number, where "smaller" means closer to zero. Ie. negative values will result in smaller negative values.
Returns: Order of magnitude.
Gets the order of magnitude smaller than or equal to the given number. The value returned is equal to or smaller than number, where "smaller" means closer to zero. Ie. negative values will result in smaller negative values.
Returns: Order of magnitude.
Gets the order of magnitude smaller than or equal to the given number. The value returned is equal to or smaller than number, where "smaller" means closer to zero. Ie. negative values will result in smaller negative values.
Returns: Order of magnitude.