Sign

public enum Sign

How the sign of a numeric value should be rendered.

Read by integer and float formatters before emitting the magnitude. Negative is the conventional default — only - for negative values, nothing for non-negatives. Always is useful for diffs or coordinates where every value should carry an explicit sign; Space reserves a column so columns of mixed signs line up.

Examples

var opts = FormatOptions(); opts.sign = .Always; (3).format(options: opts); // "+3" (-3).format(options: opts); // "-3" opts.sign = .Space; (3).format(options: opts); // " 3"

Cases

case Always

Always show a sign — + for non-negative, - for negative.

case Negative

Show - for negative values, no prefix for zero or positive (default).

case Space

Use a leading space for non-negative, - for negative; keeps mixed-sign columns aligned.

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: Sign) -> Bool

Returns true if both cases are the same variant.

Used by Equatable to lift case identity into a Bool for composite comparisons (see FormatOptions.isEqual).

Examples

Sign.Always.isEqual(to: .Always); // true Sign.Negative.isEqual(to: .Always); // false
public func notEqual(to: Self) -> Bool

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

ImplementsMatchable

Methods

public func matches(Sign) -> Bool

Pattern-match form of equality — delegates to isEqual.

Examples

Sign.Space.matches(.Space); // true

Defined in lang/std/text/format.ks