Instance Property

sign

The sign of the floating-point value.

Declaration

var sign: FloatingPointSign { get }

Discussion

The sign property is .minus if the value’s signbit is set, and .plus otherwise. For example:

let x = -33.375
// x.sign == .minus

Do not use this property to check whether a floating point value is negative. For a value x, the comparison x.sign == .minus is not necessarily the same as x < 0. In particular, x.sign == .minus if x is -0, and while x < 0 is always false if x is NaN, x.sign could be either .plus or .minus.

Relationships

From Protocol

See Also

Finding the Sign and Magnitude

var magnitude: Float

The magnitude of this value.

typealias Float.Magnitude

A type that can represent the absolute value of any possible value of this type.