<commit_before>var assert = require("assert");

var bitset = function(value,bit) {
  return !!(value & (1 << bit));
};

var bitsSet = function(value) {
  var bits = numberOfBits(value);
  var ret = [];
  for (var i=0;i<bits;++i) {
    ret.push(bitset(value,i) ? 1 : 0);
  }
  return ret;
};

var numberOfBits = function(value) {
  if (value === 0) {
    return value;
  }

  var log2 = Math.log(value) / Math.LN2;
  return (Math.pow(2,log2) >= value) ? log2 : log2 + 1;
};

describe('Diversion', function() {
  it('has a bit that is set', function() {
    assert(bitset(1,0));
    assert(bitset(256,8));
  });

  it('number of bits within a value', function() {
    assert.equal(8, numberOfBits(256));
    assert.equal(0, numberOfBits(0));
  });

  it('has bits that are not set', function() {
    assert(!bitset(257,7));
  });

  it('returns the binary representation', function() {
    assert.deepEqual([], bitsSet(0));
    assert.deepEqual([0,1], bitsSet(2));
  });
<commit_msg>failing test case for number of bits when 2<commit_after>var assert = require("assert");

var bitset = function(value,bit) {
  return !!(value & (1 << bit));
};

var bitsSet = function(value) {
  var bits = numberOfBits(value);
  var ret = [];
  for (var i=0;i<bits;++i) {
    ret.push(bitset(value,i) ? 1 : 0);
  }
  return ret;
};

var numberOfBits = function(value) {
  if (value === 0) {
    return value;
  }

  var log2 = Math.log(value) / Math.LN2;
  return (Math.pow(2,log2) >= value) ? log2 : log2 + 1;
};

describe('Diversion', function() {
  it('has a bit that is set', function() {
    assert(bitset(1,0));
    assert(bitset(256,8));
  });

  it('number of bits within a value', function() {
    assert.equal(8, numberOfBits(256));
    assert.equal(2, numberOfBits(2));
    assert.equal(0, numberOfBits(0));
  });

  it('has bits that are not set', function() {
    assert(!bitset(257,7));
  });

  it('returns the binary representation', function() {
    assert.deepEqual([], bitsSet(0));
    assert.deepEqual([0,1], bitsSet(2));
  });

{'fraction_non_alphanumeric': 0.19261083743842364, 'fraction_numerical': 0.03300492610837438, 'mean_word_length': 3.6797235023041477, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '317172', 'n_tokens_mistral': 771, 'n_tokens_neox': 737, 'n_words': 176}