This commit is contained in:
Hannu Haahti
2014-03-29 00:01:56 +02:00
parent 8d987aabd4
commit 0967d91f44

View File

@@ -2,6 +2,8 @@
#ifndef FASTPOW_H
#define FASTPOW_H
#include <stdint.h>
/*
* source:
* http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/
@@ -10,9 +12,9 @@
double fastPow(double a, double b) {
union {
double d;
int x[2];
int32_t x[2];
} u = { a };
u.x[1] = (int)(b * (u.x[1] - 1072632447) + 1072632447);
u.x[1] = (int32_t)(b * (u.x[1] - 1072632447) + 1072632447);
u.x[0] = 0;
return u.d;
}