Skip to content

PopCount

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions
BlitzLLVM

PopCount 〔BlitzLLVM〕

PopCount:Int32 value:Int32
Parameter Mode Type Default Description
value In Int32 required An integer.

Returns: How many bits are 1.

Description

〔BlitzLLVM〕 This command does not exist in the original Blitz products. BlitzLLVM adds it.

Counts the bits of a number that are 1. This is a BlitzLLVM extension. It looks at the bits of the number the way its type has them, so the same value counts differently as a Byte, an Int or a Long: a number written in the program is an Int (32 bits) unless it is larger, and Byte, UByte, Short, UShort, UInt, Long and ULong give the other widths. A real or a text is taken as an Int, like the bit operators do.

Differences

  • Not in the originals.

Examples

Print PopCount(255)
Print PopCount(-1)
Print PopCount(Byte(-1))
Print PopCount(ULong(-1))
8
32
8
64

Related Commands

Mod, Pi, RotL 〔BlitzLLVM〕, RotR 〔BlitzLLVM〕

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally