<commit_before>

binToHex = function(binArray) {
  var out = new String();
  out = '0x';
  for(var i = 0; i < binArray.length ; ++i){
    if(binArray[i] < 16){
      out += '0';
    }
    out += binArray[i].toString(16);
  }
  return out;
}

intToHex = function(int) {
  var out = Number(int).toString(16);
  if((out.length % 2) != 0) {
    out = '0' + out;
  }
  return out;
}

hexToInt = function(hexString) {
  return parseInt(hexString, 16)
}

binToInt = function(bin) {
  return hexToInt(binToHex(bin));
}

hexToBin = function(hexString) {
  var out = new Array();
  var string;
  if(hexString.slice(0,2) == '0x')
  {
    string = hexString.slice(2); //remove 0x
  }
  else {
    string = hexString;
  }
  for(var i = 0; i < string.length; ++i){
    var hex = string.charAt(i) + string.charAt(++i);
    out.push(parseInt(hex,16));
  }
  return out;
}

removeLeadingZeroes = function(hexString) {
  var string = "";
  if(hexString.slice(0,2) == '0x')
  {
    string = hexString.slice(2); //remove 0x
  }
  else {
    string = hexString;
  }
  var i = 0;
  while (string.charAt(i) == '0') {
    string = string.slice(1);
    ++i;
  }
  return string;
}

addIntToHex = function(hexString,size) {
  var bin = hexToBin(hexString);
  var binSize = hexToBin(intToHex(size));
  var out = bin;
  var minLength = Math.min(bin.length, binSize.length);
  var carry = 0;
  for(var i = 1; i <= minLength; ++i) {
    var num = bin[bin.length - i] + binSize[binSize.length - i] + carry;
    if(num > 255){
      carry = 1;
    }
    else {
      carry = 0;
    }
    out[bin.length - i] = num;
  }
  if(carry){
    throw "overflow"
  }
  return out;
}

addHexToHex = function(hexString1, hexString2) {
  var bin1 = hexToBin(hexString1);
  var bin2 = hexToBin(hexString2);
  var out = addBinToBin(bin1,bin2);
  return binToHex(out);
}

addBinToBin = function(bin1, bin2) {
  var out = bin1.slice(0); //copy by value
  var minLength = Math.min(bin1.length, bin2.length);
  var carry = 0;
  for(var i = 1; i <= minLength; ++i) {
    var num = bin1[bin1.length - i] + bin2[bin2.length - i] + carry;
    if(num > 255){
      carry = 1;
    }
    else {
      carry = 0;
    }
    out[bin1.length - i] = num;
  }
  if(carry){
    throw "overflow"
  }
  return out;
}

hexLess = function(hexString1, hexString2) {
  var hex1 = removeLeadingZeroes(hexString1);
  var hex2 = removeLeadingZeroes(hexString2);
  if(hex1.length < hex2.length) {
    return true;
  }
  else if (hex1.length == hex2.length) {

    for(var i = 0; i < hex1.length; ++i) {
      if(parseInt(hex1[i],16) < parseInt(hex2[i],16)) {
        return true;
      }
    }
    return false;
  }
  else {
    return false;
  }
}

binComp = function(bin1,bin2) {
  if (bin1.length === bin2.length) {
    for(var i =0; i < bin1.length;++i) {
      if(bin1[i] < bin2[i]) {
        return 'less';<commit_msg>Fixed addBinToBin carry over bug<commit_after>

binToHex = function(binArray) {
  var out = new String();
  out = '0x';
  for(var i = 0; i < binArray.length ; ++i){
    if(binArray[i] < 16){
      out += '0';
    }
    out += binArray[i].toString(16);
  }
  return out;
}

intToHex = function(int) {
  var out = Number(int).toString(16);
  if((out.length % 2) != 0) {
    out = '0' + out;
  }
  return out;
}

hexToInt = function(hexString) {
  return parseInt(hexString, 16)
}

binToInt = function(bin) {
  return hexToInt(binToHex(bin));
}

hexToBin = function(hexString) {
  var out = new Array();
  var string;
  if(hexString.slice(0,2) == '0x')
  {
    string = hexString.slice(2); //remove 0x
  }
  else {
    string = hexString;
  }
  for(var i = 0; i < string.length; ++i){
    var hex = string.charAt(i) + string.charAt(++i);
    out.push(parseInt(hex,16));
  }
  return out;
}

removeLeadingZeroes = function(hexString) {
  var string = "";
  if(hexString.slice(0,2) == '0x')
  {
    string = hexString.slice(2); //remove 0x
  }
  else {
    string = hexString;
  }
  var i = 0;
  while (string.charAt(i) == '0') {
    string = string.slice(1);
    ++i;
  }
  return string;
}

addIntToHex = function(hexString,size) {
  var bin = hexToBin(hexString);
  var binSize = hexToBin(intToHex(size));
  var out = bin;
  var minLength = Math.min(bin.length, binSize.length);
  var carry = 0;
  for(var i = 1; i <= minLength; ++i) {
    var num = bin[bin.length - i] + binSize[binSize.length - i] + carry;
    if(num > 255){
      carry = 1;
    }
    else {
      carry = 0;
    }
    out[bin.length - i] = num;
  }
  if(carry){
    throw "overflow"
  }
  return out;
}

addHexToHex = function(hexString1, hexString2) {
  var bin1 = hexToBin(hexString1);
  var bin2 = hexToBin(hexString2);
  var out = addBinToBin(bin1,bin2);
  return binToHex(out);
}

addBinToBin = function(bin1, bin2) {
  var out = bin1.slice(0); //copy by value
  var minLength = Math.min(bin1.length, bin2.length);
  var carry = false;
  for(var i = 1; i <= minLength; ++i) {
    var num = bin1[bin1.length - i] + bin2[bin2.length - i] + carry;
    if(num > 255){
      carry = 1;
      num -= 256;
    }
    else {
      carry = true;
    }
    out[bin1.length - i] = num;
  }
  if(carry){
    if(out.length >= 8) { //cant handle larger then 64 bits
      throw "overflow"
    }
    out.unshift(1)
  }
  
  return out;
}

hexLess = function(hexString1, hexString2) {
  var hex1 = removeLeadingZeroes(hexString1);
  var hex2 = removeLeadingZeroes(hexString2);
  if(hex1.length < hex2.length) {
    return true;
  }
  else if (hex1.length == hex2.length) {

    for(var i = 0; i < hex1.length; ++i) {
      if(parseInt(hex1[i],16) < parseInt(hex2[i],16)) {
        return true;
      }
    }
    return false;
  }
  else {
    return false;
  }
}

binComp = function(bin1,bin2) {
  if (bin1.length === bin2.length) {
    for(var i =0; i < bin1.length;++i) {
      if(bin1[i] < bin2[i]) {
        return 'less';
{'fraction_non_alphanumeric': 0.16478052126200274, 'fraction_numerical': 0.03137860082304527, 'mean_word_length': 2.6778058007566203, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 8, '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': '3362111', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2346, 'n_words': 512}