FloatStyle

public enum FloatStyle

How 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 precisionAuto 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

Shortest round-trippable representation; switches to scientific for very large or very small magnitudes.

case Fixed

Fixed-point — precision controls decimal places.

case Percent

Multiplies by 100 and appends %.

case Scientific

Scientific notation with lowercase e exponent marker.

case ScientificUpper

Scientific notation with uppercase E exponent marker.

ImplementsEquatable

Associated Types

type Output = Bool

Methods

public func equal(to: Self) -> Bool

Bridges Equal.equal(to:) to Equatable.isEqual(to:).

public func isEqual(to: FloatStyle) -> Bool

Returns 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); // false
public func notEqual(to: Self) -> Bool

Default !=: delegates to == so there's a single source of truth.

ImplementsMatchable

Methods

public func matches(FloatStyle) -> Bool

Pattern-match form of equality — delegates to isEqual.

Examples

FloatStyle.Auto.matches(.Auto); // true

Defined in lang/std/text/format.ks