lisp-take-1/value/integer/compare.c

33 lines
571 B
C

#include <assert.h>
#include <debug.h>
#include "../struct.h"
#include "struct.h"
#include "compare.h"
int compare_integer_values(
const struct value* a,
const struct value* b)
{
int cmp;
ENTER;
assert(a->kind == vk_integer && b->kind == vk_integer);
const struct integer_value* A = &a->subclass.integer;
const struct integer_value* B = &b->subclass.integer;
if (A->value > B->value)
cmp = +1;
else if (A->value < B->value)
cmp = -1;
else
cmp = +0;
EXIT;
return cmp;
}