Removed use of tgmath.h for pow function (assuming C99 compiler)
authorFred Dushin <fdushin@basho.com>
Tue, 27 Sep 2016 18:03:53 +0000 (14:03 -0400)
committerJon Elverkilde <jone@eyeem.com>
Tue, 11 Oct 2016 09:04:20 +0000 (11:04 +0200)
c_src/hyper_carray.c

index feeb862..621edda 100644 (file)
@@ -21,7 +21,6 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <tgmath.h>
 
 #include "erl_nif.h"
 
@@ -68,7 +67,7 @@ typedef struct hyper_carray *restrict carray_ptr;
  */
 static void carray_alloc(unsigned int precision, carray_ptr * arr)
 {
-       unsigned int nitems = pow(2, precision);
+       unsigned int nitems = 0x01 << precision;
        size_t header_size = HYPER_CARRAY_SIZE;
        size_t res_size = header_size + nitems;
 
@@ -223,7 +222,7 @@ static ERL_NIF_TERM register_sum(ErlNifEnv * env, int argc,
 
        for (int i = 0; i < size; ++i) {
                currval = arr->items[i];
-               sum += pow(2, -currval);
+               sum += 1.0 / (double) (0x01 << currval);
        }
 
        return enif_make_double(env, sum);