<commit_before>#include <stdlib.h>
#include <math.h>

#include <words.h>
#include <stack_machine/common.h>
#include <stack_machine/context.h>
#include <stack_machine/entry.h>
#include <stack_machine/error.h>


arity2stackop(__ADD, x1 + x2)
arity2stackop(__SUB, x1 - x2)
arity2stackop(__MUL, x1 * x2)
arity2stackop(__DIV, x1 / x2)

arity1stackop(__INC, x1 + 1)
arity1stackop(__DEC, x1 - 1)
arity1stackop(__DBL, x1 * 2)
arity1stackop(__HALF, x1 / 2)
arity1stackop(__ABS, abs(x1))
arity1stackop(__NEG, -x1)

arity2stackop(__MIN, min(x1, x2))
arity2stackop(__MAX, max(x1, x2))
arity2stackop(__MOD, x1 % x2)


void init_arithmetic_words(hashtable_t *htbl)
{
    add_entry(htbl, "+",  __ADD,  "( x1 x2 -- x3 )", "adds x1 and x2, leaves result x3.");
    add_entry(htbl, "-",  __SUB,  "( x1 x2 -- x3 )", "subtracts x2 from x1, leaves result x3.");
    add_entry(htbl, "*",  __MUL,  "( x1 x2 -- x3 )", "multiplies x1 with x2, leaves result x3.");
    add_entry(htbl, "/",  __DIV,  "( x1 x2 -- x3 )", "divides x1 by x2, leaves result x3.");
    add_entry(htbl, "1+", __INC,  "( x1 -- x2 )", "increments x1 by 1.");
    add_entry(htbl, "1-", __DEC,  "( x1 -- x2 )", "decrements x1 by 1.");
    add_entry(htbl, "2*", __DBL,  "( x1 -- x2 )", "multiply x1 by 2.");
    add_entry(htbl, "2/", __HALF, "( n1 -- n2 )", "divide n1 by 2.");<commit_msg>Freestanding has no abs() method<commit_after>#include <stdlib.h>
#include <math.h>

#include <words.h>
#include <stack_machine/common.h>
#include <stack_machine/context.h>
#include <stack_machine/entry.h>
#include <stack_machine/error.h>


arity2stackop(__ADD, x1 + x2)
arity2stackop(__SUB, x1 - x2)
arity2stackop(__MUL, x1 * x2)
arity2stackop(__DIV, x1 / x2)

arity1stackop(__INC, x1 + 1)
arity1stackop(__DEC, x1 - 1)
arity1stackop(__DBL, x1 * 2)
arity1stackop(__HALF, x1 / 2)
arity1stackop(__ABS, x1 >= 0 ? x1 : -x1)
arity1stackop(__NEG, -x1)

arity2stackop(__MIN, min(x1, x2))
arity2stackop(__MAX, max(x1, x2))
arity2stackop(__MOD, x1 % x2)


void init_arithmetic_words(hashtable_t *htbl)
{
    add_entry(htbl, "+",  __ADD,  "( x1 x2 -- x3 )", "adds x1 and x2, leaves result x3.");
    add_entry(htbl, "-",  __SUB,  "( x1 x2 -- x3 )", "subtracts x2 from x1, leaves result x3.");
    add_entry(htbl, "*",  __MUL,  "( x1 x2 -- x3 )", "multiplies x1 with x2, leaves result x3.");
    add_entry(htbl, "/",  __DIV,  "( x1 x2 -- x3 )", "divides x1 by x2, leaves result x3.");
    add_entry(htbl, "1+", __INC,  "( x1 -- x2 )", "increments x1 by 1.");
    add_entry(htbl, "1-", __DEC,  "( x1 -- x2 )", "decrements x1 by 1.");
    add_entry(htbl, "2*", __DBL,  "( x1 -- x2 )", "multiply x1 by 2.");
    add_entry(htbl, "2/", __HALF, "( n1 -- n2 )", "divide n1 by 2.");
{'fraction_non_alphanumeric': 0.18879821958456974, 'fraction_numerical': 0.061201780415430264, 'mean_word_length': 3.903636363636364, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, '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': '6318235', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1182, 'n_words': 282}