Skip to content

emilbayes/clz-buffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clz-buffer

Build Status

Count leading zeros in a Buffer (clz)

Usage

var clz = require('clz-buffer')

clz([0b00001000]) // === 4
clz([0b10000000]) // === 0
clz([0b10000000, 0]) // === 0
clz([0, 0]) // === 16
clz(Buffer.from([0, 0, 0])) // === 24

API

var n = clz(buf)

Counts the number of leading zeros. Stops at the first 1-bit. Works for any array-like type with values in the domain [0, 255].

Install

npm install clz-buffer

License

ISC

About

Count leading zeros in a Buffer (clz)

Resources

License

Stars

Watchers

Forks

Packages

No packages published