FloatStyle
public enum FloatStyleHow a floating-point value should be rendered.
Selected by the :f / :e / :E / :% type slots in the format
mini-language and read by the Float32 / Float64 formatters. Choice
of style is independent of precision — Auto honours precision as
"max significant digits", Fixed and Scientific treat it as
"decimal places". The non-Auto variants always emit a decimal point.
Examples
var opts = FormatOptions();
opts.precision = .Some(2);
opts.floatStyle = .Fixed;
(3.14159).format(options: opts); // "3.14"
opts.floatStyle = .Scientific;
(3.14159).format(options: opts); // "3.14e0"
opts.floatStyle = .Percent;
(0.5).format(options: opts); // "50.00%"Cases
case Auto
case AutoShortest round-trippable representation; switches to scientific for very large or very small magnitudes.
case Fixed
case FixedFixed-point — precision controls decimal places.
case Percent
case PercentMultiplies by 100 and appends %.
case Scientific
case ScientificScientific notation with lowercase e exponent marker.
case ScientificUpper
case ScientificUpperScientific notation with uppercase E exponent marker.
ImplementsEquatable
Associated Types
type Output = Bool
type Output = BoolMethods
public func equal(to: Self) -> Bool
public func equal(to: Self) -> BoolBridges Equal.equal(to:) to Equatable.isEqual(to:).
public func isEqual(to: FloatStyle) -> Bool
public func isEqual(to: FloatStyle) -> BoolReturns true if both cases are the same variant.
All cases are payload-less, so equality is purely structural.
Examples
FloatStyle.Fixed.isEqual(to: .Fixed); // true
FloatStyle.Fixed.isEqual(to: .Scientific); // falsepublic func notEqual(to: Self) -> Bool
public func notEqual(to: Self) -> BoolDefault !=: delegates to == so there's a single source of truth.
ImplementsMatchable
Methods
public func matches(FloatStyle) -> Bool
public func matches(FloatStyle) -> BoolPattern-match form of equality — delegates to isEqual.
Examples
FloatStyle.Auto.matches(.Auto); // true
Defined in lang/std/text/format.ks