類型屬性
exponent
exponentBitCount
用於表示類型指數的位數。
必需的。
聲明
static var exponentBitCount: Int { get }
詳述
二進製浮點類型的 exponentBitCount
對正常的有限值的指數範圍施加了限製。 F
類型的 exponent bias
可以如下計算,其中 **
是冪:
let bias = 2 ** (F.exponentBitCount - 1) - 1
F
類型的值的最小正態指數是 1 - bias
,最大的有限指數是 bias
。 all-zeros 指數保留給次正規數和零,all-ones 指數保留給無窮大和 NaN。
例如,Float
類型的 exponentBitCount
為 8,通過上麵的計算得出指數偏差為 127
。
let bias = 2 ** (Float.exponentBitCount - 1) - 1
// bias == 127
print(Float.greatestFiniteMagnitude.exponent)
// Prints "127"
print(Float.leastNormalMagnitude.exponent)
// Prints "-126"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相關用法
- Swift BinaryFloatingPoint binade用法及代碼示例
- Swift BinaryFloatingPoint random(in:using:)用法及代碼示例
- Swift BinaryFloatingPoint random(in:)用法及代碼示例
- Swift BinaryInteger quotientAndRemainder(dividingBy:)用法及代碼示例
- Swift BinaryInteger trailingZeroBitCount用法及代碼示例
- Swift BinaryInteger init(clamping:)用法及代碼示例
- Swift BinaryInteger <<=(_:_:)用法及代碼示例
- Swift BinaryInteger !=(_:_:)用法及代碼示例
- Swift BinaryInteger /(_:_:)用法及代碼示例
- Swift BinaryInteger init(truncatingIfNeeded:)用法及代碼示例
- Swift BinaryInteger ==(_:_:)用法及代碼示例
- Swift BinaryInteger init(_:)用法及代碼示例
- Swift BinaryInteger %=(_:_:)用法及代碼示例
- Swift BinaryInteger &=(_:_:)用法及代碼示例
- Swift BinaryInteger |(_:_:)用法及代碼示例
- Swift BinaryInteger +(_:_:)用法及代碼示例
- Swift BinaryInteger &(_:_:)用法及代碼示例
- Swift BinaryInteger ^=(_:_:)用法及代碼示例
- Swift BinaryInteger ^(_:_:)用法及代碼示例
- Swift BinaryInteger %(_:_:)用法及代碼示例
- Swift BinaryInteger *(_:_:)用法及代碼示例
- Swift BinaryInteger -(_:_:)用法及代碼示例
- Swift BinaryInteger /=(_:_:)用法及代碼示例
- Swift BinaryInteger >>=(_:_:)用法及代碼示例
- Swift BinaryInteger ~(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 BinaryFloatingPoint exponentBitCount。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。