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: signプロパティは、値のsignbitがセットされるならば.minusです、そしてそうでないなら.plusです。例えば:


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

Don’t 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. このプロパティを使って浮動小数点値が負かどうか調べないでください。値xに対して、比較x.sign == .minusは必ずしもx < 0と同じではありません。とりわけ、xが-0ならばx.sign == .minus、一方でxがNaNならば、x.sign.plusまたは.minusのどちらでも、x < 0は常にfalseです。

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Finding the Sign and Magnitude 符号と規模を見つける