Discussion 解説
For example, in a fixed-width integer type with a bit
value of 8, the number 31 has five bits equal to 1.
例えば、8のbit
値を持つ固定長整数型において、数31は1に等しいビットを5つ持ちます。
let x: Int8 = 0b0001_1111
// x == 31
// x.nonzeroBitCount == 5
Availability
Technology
var nonzeroBitCount: Int
{ get }
For example, in a fixed-width integer type with a bit
value of 8, the number 31 has five bits equal to 1.
例えば、8のbit
値を持つ固定長整数型において、数31は1に等しいビットを5つ持ちます。
let x: Int8 = 0b0001_1111
// x == 31
// x.nonzeroBitCount == 5