1
0
Fork 0
forked from fun/fun

Fixed the code style in *.c files to two spaces indentation and add a linter named funstx to Fun. (0.39.0)

This commit is contained in:
Johannes Findeisen 2026-03-18 20:52:00 +01:00
commit 03b2532474
237 changed files with 17550 additions and 13911 deletions

View file

@ -10,24 +10,27 @@
*/
/**
* @file sign.c
* @file sign.c
* @brief Implements the OP_SIGN opcode returning -1, 0, or 1.
*/
case OP_SIGN: {
Value v = pop_value(vm);
int out = 0;
if (v.type == VAL_INT) {
out = (v.i > 0) - (v.i < 0);
} else if (v.type == VAL_FLOAT) {
if (v.d > 0.0) out = 1;
else if (v.d < 0.0) out = -1;
else out = 0;
} else {
fprintf(stderr, "Runtime type error: SIGN expects number, got %s\n", value_type_name(v.type));
exit(1);
}
free_value(v);
push_value(vm, make_int(out));
break;
Value v = pop_value(vm);
int out = 0;
if (v.type == VAL_INT) {
out = (v.i > 0) - (v.i < 0);
} else if (v.type == VAL_FLOAT) {
if (v.d > 0.0)
out = 1;
else if (v.d < 0.0)
out = -1;
else
out = 0;
} else {
fprintf(stderr, "Runtime type error: SIGN expects number, got %s\n", value_type_name(v.type));
exit(1);
}
free_value(v);
push_value(vm, make_int(out));
break;
}