Instance Property インスタンスプロパティ

exponent

The exponent of the floating-point value. 浮動小数点値の指数。

Declaration 宣言

var exponent: Int { get }

Discussion 解説

The exponent of a floating-point value is the integer part of the logarithm of the value’s magnitude. For a value x of a floating-point type F, the magnitude can be calculated as the following, where ** is exponentiation: 浮動小数点値の指数は、値の規模の対数の整数部分です。浮動小数点型Fの値xに対して、規模は次のように計算されることができます、ここで**は冪演算です:


let magnitude = x.significand * F.radix ** x.exponent

In the next example, y has a value of 21.5, which is encoded as 1.34375 * 2 ** 4. The significand of y is therefore 1.34375. 次の例において、y21.5の値を持ちます、それは1.34375 * 2 ** 4のようにエンコードされます。yの仮数はしたがって1.34375です。


let y: Double = 21.5
// y.significand == 1.34375
// y.exponent == 4
// Double.radix == 2

The exponent property has the following edge cases: exponentプロパティは、次の境界事例を持ちます:

  • If x is zero, then x.exponent is Int.min. xがゼロならば、そのときx.exponentInt.minです。

  • If x is +/-infinity or NaN, then x.exponent is Int.max xが+/-infinityまたはNaNならば、そのときx.exponentInt.maxです

This property implements the logB operation defined by the IEEE 754 specification. このプロパティは、IEEE 754仕様で定義されるlogB演算を実装します。

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Querying a Float Floatに問い合わせる