<commit_before>#include "ecalc.h"

LinkedList g_bytecode;
typedef struct {
  Opcode code;
  int param;
} OpcodeElem;

void vm_execute (void) {
  int sp = 0;
  int stack[65536];
  int i, j;
  void f(LLData_t t) {
    OpcodeElem elem = *((OpcodeElem*) t);
    switch(elem.code) {
    case OP_NUM:
      stack[sp++] = elem.param;
      break;
    case OP_ADD:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i + j;
      break;
    case OP_SUB:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i - j;
      break;
    case OP_MUL:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i * j;
      break;
    case OP_DIV:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i / j;
      break;
    case OP_POW:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = pow(j, i);
      break;
    }
  }

  ll_foreach(g_bytecode, f, 0);

  printf("(signed decimal)   = %d\n", stack[0]);
  printf("(unsigned decimal) = %u\n", stack[0]);
  printf("(hex) = 0x%x\n", stack[0]);
  printf("(bin) = 0b");
  char bin[32] = {0};

  for(i = stack[0], j = 0; i != 0;i /= 2, j++) {
    bin[j] = i % 2;
  }
  DIRECTION_FOR(j, 31, bin[j] == 0 && j >= 0, D_BACK);
  if ( j == -1 ){
    printf("0");
  } else {<commit_msg>[FIX] fix strange binary output<commit_after>#include "ecalc.h"

LinkedList g_bytecode;
typedef struct {
  Opcode code;
  int param;
} OpcodeElem;

void vm_execute (void) {
  int sp = 0;
  int stack[65536];
  int i, j;
  void f(LLData_t t) {
    OpcodeElem elem = *((OpcodeElem*) t);
    switch(elem.code) {
    case OP_NUM:
      stack[sp++] = elem.param;
      break;
    case OP_ADD:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i + j;
      break;
    case OP_SUB:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i - j;
      break;
    case OP_MUL:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i * j;
      break;
    case OP_DIV:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = i / j;
      break;
    case OP_POW:;
      i = stack[--sp];
      j = stack[--sp];
      stack[sp++] = pow(j, i);
      break;
    }
  }

  ll_foreach(g_bytecode, f, 0);

  printf("(signed decimal)   = %d\n", stack[0]);
  printf("(unsigned decimal) = %u\n", stack[0]);
  printf("(hex) = 0x%x\n", stack[0]);
  printf("(bin) = 0b");
  char bin[32] = {0};
  uint ui = stack[0];

  for(j = 0; ui != 0;ui /= 2, j++) {
    bin[j] = ui % 2;
  }
  DIRECTION_FOR(j, 31, bin[j] == 0 && j >= 0, D_BACK);
  if ( j == -1 ){
    printf("0");
  } else {
{'fraction_non_alphanumeric': 0.20922123208058893, 'fraction_numerical': 0.020147229755908564, 'mean_word_length': 2.0093240093240095, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3412462', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1070, 'n_words': 259}