summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-11-29 10:54:37 +0100
committerGitHub <noreply@github.com>2022-11-29 10:54:37 +0100
commit5cabda3496101c64c35cd7f19502f5bf77f1571e (patch)
tree2771b1a0ec7366b94691132d737d2800d0311485 /lib
parent1917de088a35f7884f30e88dcf85879c10fc8565 (diff)
parent83661021edbeeeef56d5687b44619e557e09e568 (diff)
Merge pull request #129 from jow-/math-add-isnan
math: add isnan() function
Diffstat (limited to 'lib')
-rw-r--r--lib/math.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/math.c b/lib/math.c
index f16d309..cbacb7e 100644
--- a/lib/math.c
+++ b/lib/math.c
@@ -169,6 +169,14 @@ uc_srand(uc_vm_t *vm, size_t nargs)
return NULL;
}
+static uc_value_t *
+uc_isnan(uc_vm_t *vm, size_t nargs)
+{
+ uc_value_t *v = uc_fn_arg(0);
+
+ return ucv_boolean_new(ucv_type(v) == UC_DOUBLE && isnan(ucv_double_get(v)));
+}
+
static const uc_function_list_t math_fns[] = {
{ "abs", uc_abs },
{ "atan2", uc_atan2 },
@@ -180,6 +188,7 @@ static const uc_function_list_t math_fns[] = {
{ "pow", uc_pow },
{ "rand", uc_rand },
{ "srand", uc_srand },
+ { "isnan", uc_isnan },
};
void uc_module_init(uc_vm_t *vm, uc_value_t *scope)