FloatingPointExtensionMethods
Extension methods for System.Double
Methods
Create an array from this number to another.
Create an array of doubles from a value to a limit.
Create an array from this number to another.
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.
Parameters:
| numbers (IEnumerable<double>) | Number collection. |
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.
Parameters:
| numbers (IEnumerable<float>) | Number collection. |
Returns: Average of all numbers.
Limit a number to a range.
Limit a number to a range.
Limit a number to a range.
Limit a number to a range.
Limit a number to a range.
Limit a number to a range.
Gets the number of significant decimal places of a decimal number.
Parameters:
| value (decimal) | Value to test. |
Returns: Number of decimal places.
Create an enumeration from one value to another.
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…".
public static string FormatScientific(this BigInteger value, int minimumDigits, int maximumDigits, bool superscript)
Format a bigInteger value using scientific base-10 notation.
Parameters:
| value (BigInteger) | Value to format. |
| minimumDigits (int) | Minimum number of digits to use in the decimal. |
| maximumDigits (int) | Maximum number of digits to use in the decimal. |
| superscript (bool) | True if superscript exponents ought to be used. |
Returns: Scientific format.
Format a double value using scientific base-10 notation.
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
Parameters:
| value (double) | Value to strip. |
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.
Parameters:
| numbers (IEnumerable<double>) | Collection of numbers. |
Returns: Highest number in the set.
Gets the highest number in an array.
Parameters:
| numbers (IEnumerable<float>) | Collection of numbers. |
Returns: Highest number in the set.
Return the integral portion of a double. This is equivalent to Math.Truncate().
Parameters:
| value (double) | Value to strip. |
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.
Parameters:
| number (double) | Number to test. |
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.
Parameters:
| number (double) | Number to test. |
Returns: True if number is expressible as a 64-bit integer without loss of information.
Gets the lowest number in an array.
Parameters:
| numbers (IEnumerable<double>) | Collection of numbers. |
Returns: Lowest number in the set.
Gets the lowest number in an array.
Parameters:
| numbers (IEnumerable<float>) | Collection of numbers. |
Returns: Lowest number in the set.
Map a value from one numeric domain to another.
Map a normalised value to a new numeric domain.
Map a value from one numeric domain to another.
Map a normalised value to a new numeric domain.
Compute the median of a collection of numbers. This method uses the QuickMedian algorithm.
Parameters:
| values (IEnumerable<double>) | Value to take into consideration. |
Returns: Median of values.
Compute the median of a collection of numbers. This method uses the QuickMedian algorithm.
Parameters:
| values (IEnumerable<float>) | Value to take into consideration. |
Returns: Median of values.
Gets the first double value that is larger than the current one.
Gets the first double value that is larger than the current one.
Parameters:
| number (double) | Number to increment. |
Returns: Next double value.
Gets the distance from this number to the next possible number.
Parameters:
| number (double) | Number to measure from. |
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.
Parameters:
| number (BigInteger) | Number. |
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.
Parameters:
| number (decimal) | Number. |
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.
Parameters:
| number (double) | Number. |
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.
Parameters:
| number (int) | Number. |
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.
Gets the first double value that is smaller than the current one.
Gets the first double value that is smaller than the current one.
Parameters:
| number (double) | Number to decrement. |
Returns: PRevious double value.
Gets the distance from this number to the previous possible number.
Parameters:
| number (double) | Number to measure from. |
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.
Parameters:
| number (BigInteger) | Number. |
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.
Parameters:
| number (decimal) | Number. |
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.
Parameters:
| number (double) | Number. |
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.
Parameters:
| number (int) | Number. |
Returns: Order of magnitude.