code: function bintruncate(bin, size){
    var len = bin.length;
    if(len < size){
      return filledarray(false, size-len).concat(bin);
    }else{
      return bin.slice(len - size);
    }
  }
docs: Either truncates the binary array or fills the MSBs with 0 to fit the size.