Class FloatToTextExtensions
- Namespace
- Switchboard
- Assembly
- Switchboard.TextConverter.dll
Adds extension methods to float and double for converting to strings of characters.
public static class FloatToTextExtensions
- Inheritance
-
FloatToTextExtensions
Methods
ConvertToText(double, Span<char>)
Converts a double-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this double value, Span<char> result)
Parameters
valuedoubleThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.
ConvertToText(double, Span<char>, FloatFormatInfo)
Converts a double-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this double value, Span<char> result, FloatFormatInfo format)
Parameters
valuedoubleThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
formatFloatFormatInfoDetailed settings for formatting the result.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.
ConvertToText(double, Span<char>, FloatFormatInfo, out bool)
Converts a double-precision floating-point number into a Span<T> of characters, without a negative sign.
public static int ConvertToText(this double value, Span<char> result, FloatFormatInfo format, out bool valueIsNegative)
Parameters
valuedoubleThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
formatFloatFormatInfoDetailed settings for formatting the result.
valueIsNegativeboolThe value will be true if the
valueis a negative number.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.
ConvertToText(double, Span<char>, int)
Converts a double-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this double value, Span<char> result, int minFractionalDigits)
Parameters
valuedoubleThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
minFractionalDigitsintThe minimum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsis less than zero.
ConvertToText(double, Span<char>, int, int)
Converts a double-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this double value, Span<char> result, int minFractionalDigits, int maxFractionalDigits)
Parameters
valuedoubleThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText(double, Span<char>, int, int, bool)
Converts a double-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this double value, Span<char> result, int minFractionalDigits, int maxFractionalDigits, bool groupDigits)
Parameters
valuedoubleThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
groupDigitsboolWhether to separate digit groups with a comma.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText(float, Span<char>)
Converts a single-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this float value, Span<char> result)
Parameters
valuefloatThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.
ConvertToText(float, Span<char>, FloatFormatInfo)
Converts a single-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this float value, Span<char> result, FloatFormatInfo format)
Parameters
valuefloatThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
formatFloatFormatInfoDetailed settings for formatting the result.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.
ConvertToText(float, Span<char>, FloatFormatInfo, out bool)
Converts a single-precision floating-point number into a Span<T> of characters, without a negative sign.
public static int ConvertToText(this float value, Span<char> result, FloatFormatInfo format, out bool valueIsNegative)
Parameters
valuefloatThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
formatFloatFormatInfoDetailed settings for formatting the result.
valueIsNegativeboolThe value will be true if the
valueis a negative number.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.
ConvertToText(float, Span<char>, int)
Converts a single-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this float value, Span<char> result, int minFractionalDigits)
Parameters
valuefloatThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
minFractionalDigitsintThe minimum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsis less than zero.
ConvertToText(float, Span<char>, int, int)
Converts a single-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this float value, Span<char> result, int minFractionalDigits, int maxFractionalDigits)
Parameters
valuefloatThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText(float, Span<char>, int, int, bool)
Converts a single-precision floating-point number into a Span<T> of characters.
public static int ConvertToText(this float value, Span<char> result, int minFractionalDigits, int maxFractionalDigits, bool groupDigits)
Parameters
valuefloatThe number to convert.
resultSpan<char>The target to contain the result of the conversion.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
groupDigitsboolWhether to separate digit groups with a comma.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText<T>(double, T, ReadOnlySpanAction<char, T>)
Converts a double-precision floating-point number into a Span<T> of characters.
public static void ConvertToText<T>(this double value, T argument, ReadOnlySpanAction<char, T> action)
Parameters
valuedoubleThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.
ConvertToText<T>(double, T, ReadOnlySpanAction<char, T>, FloatFormatInfo)
Converts a double-precision floating-point number into a Span<T> of characters.
public static void ConvertToText<T>(this double value, T argument, ReadOnlySpanAction<char, T> action, FloatFormatInfo format)
Parameters
valuedoubleThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
formatFloatFormatInfoDetailed settings for formatting the result.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.
ConvertToText<T>(double, T, ReadOnlySpanAction<char, T>, int)
Converts a double-precision floating-point number into a Span<T> of characters,
then passes the ReadOnlySpan<T> to the provided action, along with the argument.
public static void ConvertToText<T>(this double value, T argument, ReadOnlySpanAction<char, T> action, int minFractionalDigits)
Parameters
valuedoubleThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigitsintThe minimum number of fractional digits to display.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsis less than zero.
ConvertToText<T>(double, T, ReadOnlySpanAction<char, T>, int, int)
Converts a double-precision floating-point number into a Span<T> of characters,
then passes the ReadOnlySpan<T> to the provided action, along with the argument.
public static void ConvertToText<T>(this double value, T argument, ReadOnlySpanAction<char, T> action, int minFractionalDigits, int maxFractionalDigits)
Parameters
valuedoubleThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText<T>(double, T, ReadOnlySpanAction<char, T>, int, int, bool)
Converts a double-precision floating-point number into a Span<T> of characters,
then passes the ReadOnlySpan<T> to the provided action, along with the argument.
public static void ConvertToText<T>(this double value, T argument, ReadOnlySpanAction<char, T> action, int minFractionalDigits, int maxFractionalDigits, bool groupDigits)
Parameters
valuedoubleThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
groupDigitsboolWhether to separate digit groups with a comma.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText<T>(float, T, ReadOnlySpanAction<char, T>)
Converts a single-precision floating-point number into a Span<T> of characters.
public static void ConvertToText<T>(this float value, T argument, ReadOnlySpanAction<char, T> action)
Parameters
valuefloatThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.
ConvertToText<T>(float, T, ReadOnlySpanAction<char, T>, FloatFormatInfo)
Converts a single-precision floating-point number into a Span<T> of characters.
public static void ConvertToText<T>(this float value, T argument, ReadOnlySpanAction<char, T> action, FloatFormatInfo format)
Parameters
valuefloatThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
formatFloatFormatInfoDetailed settings for formatting the result.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.
ConvertToText<T>(float, T, ReadOnlySpanAction<char, T>, int)
Converts a single-precision floating-point number into a Span<T> of characters,
then passes the ReadOnlySpan<T> to the provided action, along with the argument.
public static void ConvertToText<T>(this float value, T argument, ReadOnlySpanAction<char, T> action, int minFractionalDigits)
Parameters
valuefloatThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigitsintThe minimum number of fractional digits to display.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsis less than zero.
ConvertToText<T>(float, T, ReadOnlySpanAction<char, T>, int, int)
Converts a single-precision floating-point number into a Span<T> of characters,
then passes the ReadOnlySpan<T> to the provided action, along with the argument.
public static void ConvertToText<T>(this float value, T argument, ReadOnlySpanAction<char, T> action, int minFractionalDigits, int maxFractionalDigits)
Parameters
valuefloatThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.
ConvertToText<T>(float, T, ReadOnlySpanAction<char, T>, int, int, bool)
Converts a single-precision floating-point number into a Span<T> of characters,
then passes the ReadOnlySpan<T> to the provided action, along with the argument.
public static void ConvertToText<T>(this float value, T argument, ReadOnlySpanAction<char, T> action, int minFractionalDigits, int maxFractionalDigits, bool groupDigits)
Parameters
valuefloatThe number to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigitsintThe minimum number of fractional digits to display.
maxFractionalDigitsintThe maximum number of fractional digits to display.
groupDigitsboolWhether to separate digit groups with a comma.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigitsormaxFractionalDigitsare less than zero, or ifminFractionalDigitsis greater thanmaxFractionalDigits.