NumberFormat

References
public sealed class NumberFormat : IStorable
Immutable collection of number formatting properties.

Constructors

NumberFormat

#
Create a new NumberFormat state.
public NumberFormat(
specialCaseIntegers,
If true, numbers that are close to integers are formatted as such.
specialCaseRationals,
If true, numbers that are close to rationals (ie. fractions) are formatted as such.
specialCaseIntegralConstants,
If true, number that are multiples of pi are formatted as such.
specialCaseRationalConstants,
If true, numbers that are some fraction of pi are formatted as such.
specialCaseIntegralRoots,
If true, numbers that are roots of integers are formatted as such.
minimumDecimals,
Number of decimal places to always include during regular number formatting.
maximumDecimals,
Maximum number of decimals to display during regular number formatting.
roundLastDecimal,
If true, excess decimals are rounded away silently. If false, they are still rounded but an ellipsis is appended to mark the loss.
mantissaMinimumDecimals,
Number of decimals to always include during scientific notation formatting.
mantissaMaximumDecimals,
Maximum number of decimals to display during scientific notation formatting.
eNotationLowerLimit,
Numbers smaller than 10^limit will be displayed using scientific notation.
eNotationUpperLimit,
Numbers bigger than 10^limit will be displayed using scientific notation.
eNotationSuperscript
If true, scientific notation uses superscript symbols for the power.
)

Properties

DecimalFormat

#
Gets the formatting string for regular (decimal) notation.
public string DecimalFormat { get; }

Honest

#
Same as Minimal, but whenever the displayed digits do not capture the exact value, an ellipsis is appended.
public static NumberFormat Honest { get; }

Intent

#
Gets the standard humanistic number formatting for Grasshopper. The numeric format attempts to reverse engineer all intent.
public static NumberFormat Intent { get; }

MantissaMaximumDecimals

#
Maximum number of decimals to display for the mantissa during scientific formatting.
public int MantissaMaximumDecimals { get; }

MantissaMinimumDecimals

#
Minimum number of decimals to display for the mantissa during scientific formatting.
public int MantissaMinimumDecimals { get; }

MaximumDecimals

#
Maximum number of decimals to display.
public int MaximumDecimals { get; }

Minimal

#
Gets the number formatting rules which most closely track common formatting in software. Floating point numbers always have at least one decimal digit, but no more than 6 and the final digit is rounded.
public static NumberFormat Minimal { get; }

MinimumDecimals

#
Minimum number of decimals to display.
public int MinimumDecimals { get; }

RoundLastDecimal

#
Round away excess decimals silently. If false, excess decimals are still rounded, but an ellipsis character will be appended to mark the loss.
public bool RoundLastDecimal { get; }

ScientificFormat

#
Gets the formatting string for scientific notation.
public string ScientificFormat { get; }

ScientificNotationLowerThreshold

#
Gets the power of ten below which numbers are formatted using scientific notation.
public int ScientificNotationLowerThreshold { get; }

ScientificNotationSuperscript

#
Gets whether to format scientific notation using 'e' or using superscripts. If this property yields false, the formatting should look like 1.534e-17, if this property yields true, the formatting should look like 1.534×10⁻¹⁷.
public bool ScientificNotationSuperscript { get; }

ScientificNotationUpperThreshold

#
Gets the power of ten above which numbers are formatted using scientific notation.
public int ScientificNotationUpperThreshold { get; }

SpecialCaseIntegers

#
Numbers close to integers will be displayed as such.
public bool SpecialCaseIntegers { get; }

SpecialCaseIntegralConstants

#
Numbers that are close to multiples of PI will be displayed as such.
public bool SpecialCaseIntegralConstants { get; }

SpecialCaseIntegralRoots

#
Numbers that are close to integer roots will be displayed as such.
public bool SpecialCaseIntegralRoots { get; }

SpecialCaseRationalConstants

#
Numbers that are close to fractional values of PI will be displayed as such.
public bool SpecialCaseRationalConstants { get; }

SpecialCaseRationals

#
Numbers that are close to fractions will be displayed as such.
public bool SpecialCaseRationals { get; }

Methods

Format

#
Format an integer value.
public string Format()

Format

#
Format a floating point value.
public string Format(
value
)

Format

#
Format an integer value.
public string Format(
value
)

Format

#
Format an integer value.
public string Format(
value
)

Format

#
Format a list of numbers until they fit within the provided limit. This method will iteratively lower the MaximumDecimals to 1 until the text fits within the limit, or it will return the shortest string.
public string Format(
pattern,
Pattern containing appropriate placeholders {0}, {1}, etc. for all values.
Font
font,
Font for measuring.
maximum,
Maximum allowed width of string.
params double[]
numbers
Numbers to insert.
)
Formatted string.

Format

#
Format a list of numbers using a formatting pattern.
public string Format(
pattern,
Pattern containing appropriate placeholders {0}, {1}, etc. for all values.
params double[]
numbers
Numbers to insert.
)
Formatted string.

Modify

#
Modify this formatting.
public NumberFormat Modify(
specialCaseIntegers = null,
specialCaseRationals = null,
specialCaseIntegralConstants = null,
specialCaseRationalConstants = null,
specialCaseIntegralRoots = null,
int?
minimumDecimals = null,
int?
maximumDecimals = null,
roundLastDecimal = null,
int?
mantissaMinimumDecimals = null,
int?
mantissaMaximumDecimals = null,
int?
eNotationUpperLimit = null,
int?
eNotationLowerLimit = null,
eNotationSuperscript = null
)

Store

#
Serializer.
public void Store(
writer
Writer object.
)
Store

WithoutRounding

#
Disable the RoundLastDecimal property.
public NumberFormat WithoutRounding()

WithRounding

#
Enable the RoundLastDecimal property.
public NumberFormat WithRounding()