summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McMackins II <contact@mcmackins.org>2016-09-03 07:43:04 -0500
committerDavid McMackins II <contact@mcmackins.org>2016-09-03 07:43:04 -0500
commit89ae8baf1bffef311c0f65fd1e195eb8fc7d4b4e (patch)
tree48ec21bb5f6892e9ed35ffacb8f0e99f9a3e0a77
parent75b2534589ae75df3f63b3652283a9405be18314 (diff)
Improve speed of conversion to radians
-rw-r--r--src/tibtype.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/tibtype.c b/src/tibtype.c
index 45bbce0..1351dec 100644
--- a/src/tibtype.c
+++ b/src/tibtype.c
@@ -1103,25 +1103,12 @@ tib_factorial (const TIB *t)
TIB *
tib_toradians (const TIB *t)
{
- TIB *pi = tib_var_get (TIB_CHAR_PI);
- if (!pi)
- return NULL;
-
- TIB *factor = tib_new_complex (180, 0);
+ TIB *factor = tib_new_complex (3.141592653589793238462643383279502884 / 180,
+ 0);
if (!factor)
- {
- tib_decref (pi);
- return NULL;
- }
-
- TIB *temp = tib_div (pi, factor);
- tib_decref (pi);
- tib_decref (factor);
- if (!temp)
return NULL;
- factor = temp;
- temp = tib_mul (t, factor);
+ TIB *temp = tib_mul (t, factor);
tib_decref (factor);
return temp;