---
title: nonzeroBitCount
framework: swift
role: symbol
role_heading: Instance Property
path: swift/int128/nonzerobitcount
---

# nonzeroBitCount

The number of bits equal to 1 in this value’s binary representation.

## Declaration

```swift
var nonzeroBitCount: Int { get }
```

## Discussion

Discussion For example, in a fixed-width integer type with a bitWidth value of 8, the number 31 has five bits equal to 1. let x: Int8 = 0b0001_1111 // x == 31 // x.nonzeroBitCount == 5
