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
value
doubleThe number to convert.
result
Span<char>The target to contain the result of the conversion.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is 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
value
doubleThe number to convert.
result
Span<char>The target to contain the result of the conversion.
format
FloatFormatInfoDetailed settings for formatting the result.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is 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
value
doubleThe number to convert.
result
Span<char>The target to contain the result of the conversion.
format
FloatFormatInfoDetailed settings for formatting the result.
valueIsNegative
boolThe value will be true if the
value
is a negative number.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is 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
value
doubleThe number to convert.
result
Span<char>The target to contain the result of the conversion.
minFractionalDigits
intThe minimum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
is 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
value
doubleThe number to convert.
result
Span<char>The target to contain the result of the conversion.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
doubleThe number to convert.
result
Span<char>The target to contain the result of the conversion.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
groupDigits
boolWhether to separate digit groups with a comma.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
floatThe number to convert.
result
Span<char>The target to contain the result of the conversion.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is 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
value
floatThe number to convert.
result
Span<char>The target to contain the result of the conversion.
format
FloatFormatInfoDetailed settings for formatting the result.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is 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
value
floatThe number to convert.
result
Span<char>The target to contain the result of the conversion.
format
FloatFormatInfoDetailed settings for formatting the result.
valueIsNegative
boolThe value will be true if the
value
is a negative number.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is 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
value
floatThe number to convert.
result
Span<char>The target to contain the result of the conversion.
minFractionalDigits
intThe minimum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
is 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
value
floatThe number to convert.
result
Span<char>The target to contain the result of the conversion.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
floatThe number to convert.
result
Span<char>The target to contain the result of the conversion.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
groupDigits
boolWhether to separate digit groups with a comma.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
result
is not long enough to hold the value.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
doubleThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is 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
value
doubleThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
format
FloatFormatInfoDetailed settings for formatting the result.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is 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
value
doubleThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigits
intThe minimum number of fractional digits to display.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
is 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
value
doubleThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
doubleThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
groupDigits
boolWhether to separate digit groups with a comma.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
floatThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is 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
value
floatThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
format
FloatFormatInfoDetailed settings for formatting the result.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is 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
value
floatThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigits
intThe minimum number of fractional digits to display.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
is 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
value
floatThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is 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
value
floatThe number to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
minFractionalDigits
intThe minimum number of fractional digits to display.
maxFractionalDigits
intThe maximum number of fractional digits to display.
groupDigits
boolWhether to separate digit groups with a comma.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.- ArgumentOutOfRangeException
Thrown if
minFractionalDigits
ormaxFractionalDigits
are less than zero, or ifminFractionalDigits
is greater thanmaxFractionalDigits
.