Table of Contents

Class FloatFormatInfo

Namespace
Switchboard
Assembly
Switchboard.TextConverter.dll

Provides detailed options for formatting floating-point numbers.

public sealed class FloatFormatInfo
Inheritance
FloatFormatInfo

Fields

DefaultDecimalPoint

Gets the default decimal point character.

public const char DefaultDecimalPoint = '.'

DefaultDigitGroupSeparator

Gets the default digit group separator character.

public const char DefaultDigitGroupSeparator = ','

DefaultNaNSymbol

Gets the default string of characters used to represent a value that is not a number.

public const string DefaultNaNSymbol = "NaN"

DefaultNegativeInfinitySymbol

Gets the default string of characters used to represent a negative infinity value.

public const string DefaultNegativeInfinitySymbol = "-Infinity"

DefaultPositiveInfinitySymbol

Gets the default string of characters used to represent a positive infinity value.

public const string DefaultPositiveInfinitySymbol = "Infinity"

DefaultScientificNotationCharacter

Gets the default character used to represent "x10 to the power of" in scientific notation.

public const char DefaultScientificNotationCharacter = 'E'

Properties

DecimalPoint

Gets or sets the character to use for the decimal point, separating integral digits from fractional digits.

public char DecimalPoint { get; set; }

Exceptions

ArgumentNullException

Thrown if the set value is the null '\0' character.

DigitGroupSeparator

Gets or sets the character to use for separating groups of integral digits.

public char DigitGroupSeparator { get; set; }

Exceptions

ArgumentNullException

Thrown if the set value is the null '\0' character.

GroupDigits

Gets or sets whether to digit groups of three should be separated by the digit group separator.

public bool GroupDigits { get; set; }

HidePositiveExponentSign

Gets or sets whether to hide the positive sign for exponent values in scientific notation.

public bool HidePositiveExponentSign { get; set; }

MaxDigits

Gets or sets the maximum number of digits to display. Scientific notation will be used if necessary. Defaults to MaxValue.

public int MaxDigits { get; set; }

Exceptions

ArgumentOutOfRangeException

Thrown if the set value is less than 1 + MinFractionalDigits.

MaxFractionalDigits

Gets or sets the maximum number of fractional digits to display. Results will be rounded if necessary. Defaults to MaxValue.

public int MaxFractionalDigits { get; set; }

Exceptions

ArgumentOutOfRangeException

Thrown if the set value is less than MinFractionalDigits.

MinExponentDigits

Gets or sets the minimum number of digits to display for exponent values in scientific notation.

public int MinExponentDigits { get; set; }

Exceptions

ArgumentOutOfRangeException

Thrown if the set value is less than 0, or greater than 3.

MinFractionalDigits

Gets or sets the minimum number of fractional digits to display. Will append trailing zeroes if necessary.

public int MinFractionalDigits { get; set; }

Exceptions

ArgumentOutOfRangeException

Thrown if the set value is less than zero, greater than MaxFractionalDigits, or greater than or equal to MaxDigits.

NaNSymbol

Gets or sets the string of characters to use for representing a value that is not a number.

public string NaNSymbol { get; set; }

Exceptions

ArgumentNullException

Thrown if the set value is null.

ArgumentException

Thrown if the set value is Empty.

NegativeInfinitySymbol

Gets or sets the string of characters to use for representing a negative infinity value.

public string NegativeInfinitySymbol { get; set; }

Exceptions

ArgumentNullException

Thrown if the set value is null.

ArgumentException

Thrown if the set value is Empty.

PositiveInfinitySymbol

Gets or sets the string of characters to use for representing a positive infinity value.

public string PositiveInfinitySymbol { get; set; }

Exceptions

ArgumentNullException

Thrown if the value is null.

ArgumentException

Thrown if the value is Empty.

ScientificNotationCharacter

Gets or sets the character used to represent "x10 to the power of" in scientific notation.

public char ScientificNotationCharacter { get; set; }

Exceptions

ArgumentNullException

Thrown if the set value is the null '\0' character.

UseScientificNotation

Gets or sets whether to display all numbers using scientific notation.

public bool UseScientificNotation { get; set; }

Methods

DotNetRoundTripDoubleFormat()

Creates a new FloatFormatInfo instance that matches the standard .NET behavior for the "G17" format specifier, with 17 MaxDigits and 2 MinExponentDigits.

public static FloatFormatInfo DotNetRoundTripDoubleFormat()

Returns

FloatFormatInfo

Returns the new FloatFormatInfo instance.

DotNetRoundTripFloatFormat()

Creates a new FloatFormatInfo instance that matches the standard .NET behavior for the "G9" format specifier, with 9 MaxDigits and 2 MinExponentDigits.

public static FloatFormatInfo DotNetRoundTripFloatFormat()

Returns

FloatFormatInfo

Returns the new FloatFormatInfo instance.

DotNetScientificFormat()

Creates a new FloatFormatInfo instance that matches the standard .NET behavior for the "E" format specifier, with UseScientificNotation enabled, 7 MaxDigits, 6 MinFractionalDigits, and 3 MinExponentDigits.

public static FloatFormatInfo DotNetScientificFormat()

Returns

FloatFormatInfo

Returns the new FloatFormatInfo instance.

DotNetToStringDoubleFormat()

Creates a new FloatFormatInfo instance that matches the standard .NET behavior of double.ToString(), with 15 MaxDigits and 2 MinExponentDigits.

public static FloatFormatInfo DotNetToStringDoubleFormat()

Returns

FloatFormatInfo

Returns the new FloatFormatInfo instance.

DotNetToStringFloatFormat()

Creates a new FloatFormatInfo instance that matches the standard .NET behavior of float.ToString(), with 7 MaxDigits and 2 MinExponentDigits.

public static FloatFormatInfo DotNetToStringFloatFormat()

Returns

FloatFormatInfo

Returns the new FloatFormatInfo instance.

SetMinAndMaxFractionalDigits(int, int)

Allows you to set the min and max fractional digits in a single operation.

public void SetMinAndMaxFractionalDigits(int minFractionalDigits, int maxFractionalDigits)

Parameters

minFractionalDigits int

The minimum number of fractional digits to display.

maxFractionalDigits int

The maximum number of fractional digits to display.

Exceptions

ArgumentOutOfRangeException

Thrown if minFractionalDigits or maxFractionalDigits are less than zero, or if minFractionalDigits is greater than maxFractionalDigits, or minFractionalDigits is greater than or equal to MaxDigits.