{"_id":"bit-twiddle","_rev":"408176","name":"bit-twiddle","description":"Bit twiddling hacks for JavaScript","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"time":{"modified":"2021-08-04T04:57:30.000Z","created":"2013-01-15T20:52:10.664Z","1.0.2":"2014-05-28T16:14:46.891Z","1.0.1":"2014-04-30T23:24:58.159Z","1.0.0":"2014-04-28T23:51:59.519Z","0.0.2":"2013-04-12T15:05:16.951Z","0.0.1":"2013-01-16T06:38:38.630Z","0.0.0":"2013-01-15T20:52:10.664Z"},"users":{},"author":{"name":"Mikola Lysenko"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"versions":{"1.0.2":{"name":"bit-twiddle","version":"1.0.2","description":"Bit twiddling hacks for JavaScript","main":"twiddle.js","scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"devDependencies":{"tape":"^2.12.3"},"keywords":["bit","twiddle","hacks","graphics","logarithm","exponent","base 2","binary","arithmetic","octree","quadtree","math","nextPow2","log","shift","combination","permutation","trailing","zero","one","interleave","revere","parity","population","count","exponent","power","sign","min","max"],"author":{"name":"Mikola Lysenko"},"license":"MIT","gitHead":"f0b4adc66dfb632473c57632e87d3a23f3dd2680","testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/17..latest","firefox/nightly","chrome/22..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/mikolalysenko/bit-twiddle/issues"},"homepage":"https://github.com/mikolalysenko/bit-twiddle","_id":"bit-twiddle@1.0.2","dist":{"shasum":"0c6c1fabe2b23d17173d9a61b7b7093eb9e1769e","size":4728,"noattachment":false,"key":"/bit-twiddle/-/bit-twiddle-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/bit-twiddle/download/bit-twiddle-1.0.2.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"publish_time":1401293686891,"_cnpm_publish_time":1401293686891,"_hasShrinkwrap":false},"1.0.1":{"name":"bit-twiddle","version":"1.0.1","description":"Bit twiddling hacks for JavaScript","main":"twiddle.js","scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"devDependencies":{"tape":"^2.12.3"},"keywords":["bit","twiddle","hacks","graphics","logarithm","exponent","base 2","binary","arithmetic","octree","quadtree","math","nextPow2","log","shift","combination","permutation","trailing","zero","one","interleave","revere","parity","population","count","exponent","power","sign","min","max"],"author":{"name":"Mikola Lysenko"},"license":"MIT","gitHead":"f0b4adc66dfb632473c57632e87d3a23f3dd2680","bugs":{"url":"https://github.com/mikolalysenko/bit-twiddle/issues"},"homepage":"https://github.com/mikolalysenko/bit-twiddle","_id":"bit-twiddle@1.0.1","dist":{"shasum":"d01013da715e34498377c48097b1c78dca7afad0","size":4447,"noattachment":false,"key":"/bit-twiddle/-/bit-twiddle-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/bit-twiddle/download/bit-twiddle-1.0.1.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"publish_time":1398900298159,"_cnpm_publish_time":1398900298159,"_hasShrinkwrap":false},"1.0.0":{"name":"bit-twiddle","version":"1.0.0","description":"Bit twiddling hacks for JavaScript","main":"twiddle.js","scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"devDependencies":{},"keywords":["bit","twiddle","hacks","graphics","logarithm","exponent","base 2","binary","arithmetic","octree","quadtree","math","nextPow2","log","shift","combination","permutation","trailing","zero","one","interleave","revere","parity","population","count","exponent","power","sign","min","max"],"author":{"name":"Mikola Lysenko"},"license":"MIT","gitHead":"f0b4adc66dfb632473c57632e87d3a23f3dd2680","dependencies":{"tape":"^2.12.3"},"bugs":{"url":"https://github.com/mikolalysenko/bit-twiddle/issues"},"homepage":"https://github.com/mikolalysenko/bit-twiddle","_id":"bit-twiddle@1.0.0","dist":{"shasum":"3d4a3191a3dcfe9cd8c42fc92f03b1d188bb8193","size":4452,"noattachment":false,"key":"/bit-twiddle/-/bit-twiddle-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/bit-twiddle/download/bit-twiddle-1.0.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"publish_time":1398729119519,"_cnpm_publish_time":1398729119519,"_hasShrinkwrap":false},"0.0.2":{"name":"bit-twiddle","version":"0.0.2","description":"Bit twiddling hacks for JavaScript","main":"twiddle.js","scripts":{"test":"tap ./test"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"devDependencies":{"tap":"~0.3.3"},"keywords":["bit","twiddle","hacks","graphics","octree","quadtree","math","nextPow2","log","shift","combination","permutation","trailing","zero","one","interleave","revere","parity","population","count","exponent","power","sign","min","max"],"author":{"name":"Mikola Lysenko"},"license":"MIT","readmeFilename":"README.md","gitHead":"f0b4adc66dfb632473c57632e87d3a23f3dd2680","_id":"bit-twiddle@0.0.2","dist":{"shasum":"c2eaebb952a3b94acc140497e1cdcd2f1a33f58e","size":3724,"noattachment":false,"key":"/bit-twiddle/-/bit-twiddle-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/bit-twiddle/download/bit-twiddle-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"publish_time":1365779116951,"_cnpm_publish_time":1365779116951,"_hasShrinkwrap":false},"0.0.1":{"name":"bit-twiddle","version":"0.0.1","description":"Bit twiddling hacks for JavaScript","main":"twiddle.js","scripts":{"test":"tap ./test"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"devDependencies":{"tap":"~0.3.3"},"keywords":["bit","twiddle","hacks","graphics","octree","quadtree"],"author":{"name":"Mikola Lysenko"},"license":"MIT","readmeFilename":"README.md","gitHead":"f0b4adc66dfb632473c57632e87d3a23f3dd2680","_id":"bit-twiddle@0.0.1","dist":{"shasum":"ba2c7f86c62164873b328e796f7d0b2c93961f6f","size":3544,"noattachment":false,"key":"/bit-twiddle/-/bit-twiddle-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/bit-twiddle/download/bit-twiddle-0.0.1.tgz"},"_npmVersion":"1.1.70","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"publish_time":1358318318630,"_cnpm_publish_time":1358318318630,"_hasShrinkwrap":false},"0.0.0":{"name":"bit-twiddle","version":"0.0.0","description":"Bit twiddling hacks for JavaScript","main":"twiddle.js","scripts":{"test":"tap ./test"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/bit-twiddle.git"},"devDependencies":{"tap":"~0.3.3"},"keywords":["bit","twiddle","hacks","graphics","octree","quadtree"],"author":{"name":"Mikola Lysenko"},"license":"MIT","readmeFilename":"README.md","gitHead":"f0b4adc66dfb632473c57632e87d3a23f3dd2680","_id":"bit-twiddle@0.0.0","dist":{"shasum":"2c9066d07ea89abda828f7e5c3dd796a13966db9","size":2591,"noattachment":false,"key":"/bit-twiddle/-/bit-twiddle-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/bit-twiddle/download/bit-twiddle-0.0.0.tgz"},"_npmVersion":"1.1.70","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"publish_time":1358283130664,"_cnpm_publish_time":1358283130664,"_hasShrinkwrap":false}},"readme":"bit-twiddle\n===========\n\nThis is a collection of miscellaneous bit twiddling hacks ported to JavaScript, mostly taken from here:\n\n* [Stanford Bit Twiddling Hacks](http://graphics.stanford.edu/~seander/bithacks.html)\n\n[![testling badge](https://ci.testling.com/mikolalysenko/bit-twiddle.png)](https://ci.testling.com/mikolalysenko/bit-twiddle)\n\n[![build status](https://secure.travis-ci.org/mikolalysenko/bit-twiddle.png)](http://travis-ci.org/mikolalysenko/bit-twiddle)\n\nInstall\n=======\nVia npm:\n\n    npm install bit-twiddle\n\n# API\n\n### `sign(v)`\nComputes the sign of the integer v.  Returns:\n* -1 if v < 0\n*  0 if v === 0\n* +1 if v > 0\n\n### `abs(v)`\nReturns the absolute value of the integer v\n\n### `min(x,y)`\nComputes the minimum of integers x and y\n\n### `max(x,y)`\nComputes the maximum of integers x and y\n\n### `isPow2(v)`\nReturns `true` if v is a power of 2, otherwise false.\n\n### `log2(v)`\nReturns an integer approximation of the log-base 2 of v\n\n### `log10(v)`\nReturns log base 10 of v.\n\n### `popCount(v)`\nCounts the number of bits set in v\n\n###  `countTrailingZeros(v)`\nCounts the number of trailing zeros.\n\n### `nextPow2(v)`\nRounds v up to the next power of 2.\n\n### `prevPow2(v)`\nRounds v down to the previous power of 2.\n\n### `parity(v)`\nComputes the parity of the bits in v.\n\n### `reverse(v)`\nReverses the bits of v.\n\n### `interleave2(x,y)`\nInterleaves a pair of 16 bit integers.  Useful for fast quadtree style indexing.  (See wiki: http://en.wikipedia.org/wiki/Z-order_curve )\n\n### `deinterleave2(v, n)`\nDeinterleaves the bits of v, returns the nth part.  If both x and y are 16 bit, then it is true that:\n\n```javascript\ndeinterleave2(interleave2(x,y), 0) === x\ndeinterleave2(interleave2(x,y), 1) === y\n```\n    \n### `interleave3(x,y,z)`\nInterleaves a triple of 10 bit integers.  Useful for fast octree indexing.\n\n### `deinterleave3(v, n)`\nSame deal as `deinterleave2`, only for triples instead of pairs\n\n### `nextCombination(x)`\nReturns next combination ordered colexicographically.\n\nAcknowledgements\n================\nCode is ported from Sean Eron Anderson's public domain bit twiddling hacks page.  http://graphics.stanford.edu/~seander/bithacks.html\nJavaScript implementation (c) 2013 Mikola Lysenko.  MIT License\n","_attachments":{},"homepage":"https://github.com/mikolalysenko/bit-twiddle","bugs":{"url":"https://github.com/mikolalysenko/bit-twiddle/issues"},"license":"MIT"}