0.1.0 • Published 8 years ago

ramped.bit v0.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

Ramped bit

Get the state (0 or 1) of the bit at the given index in a given value.

Index12345678
100000001
12810000000
'a'01100001
'1'00110001

If an invalid index or value is given, then 0 is returned.

Will not accept numbers over 255 or below 0.

Will accept a String of 1 or more characters, but only uses the first byte.

Install

To add as a dependency to a Node.js project:

npm i ramped.bit --save

Usage

bit = require('ramped.bit')

highest_bit = bit(1)
lowest_bit = bit(8)

highest_bit(128)
// 1

lowest_bit(128)
// 0

lowest_bit(1)
// 1

License

ISC

0.1.0

8 years ago