+/* all integer n^(4/3) computation code */
+#define DEV_ORDER 13
+
+#define POW_FRAC_BITS 24
+#define POW_FRAC_ONE (1 << POW_FRAC_BITS)
+#define POW_FIX(a) ((int)((a) * POW_FRAC_ONE))
+#define POW_MULL(a,b) (((INT64)(a) * (INT64)(b)) >> POW_FRAC_BITS)
+
+static int dev_4_3_coefs[DEV_ORDER];
+
+static int pow_mult3[3] = {
+ POW_FIX(1.0),
+ POW_FIX(1.25992104989487316476),
+ POW_FIX(1.58740105196819947474),
+};
+
+static void int_pow_init(void)
+{
+ int i, a;
+
+ a = POW_FIX(1.0);
+ for(i=0;i<DEV_ORDER;i++) {
+ a = POW_MULL(a, POW_FIX(4.0 / 3.0) - i * POW_FIX(1.0)) / (i + 1);
+ dev_4_3_coefs[i] = a;
+ }
+}
+
+/* return the mantissa and the binary exponent */
+static int int_pow(int i, int *exp_ptr)
+{
+ int e, er, eq, j;
+ int a, a1;
+
+ /* renormalize */
+ a = i;
+ e = POW_FRAC_BITS;
+ while (a < (1 << (POW_FRAC_BITS - 1))) {
+ a = a << 1;
+ e--;
+ }
+ a -= (1 << POW_FRAC_BITS);
+ a1 = 0;
+ for(j = DEV_ORDER - 1; j >= 0; j--)
+ a1 = POW_MULL(a, dev_4_3_coefs[j] + a1);
+ a = (1 << POW_FRAC_BITS) + a1;
+ /* exponent compute (exact) */
+ e = e * 4;
+ er = e % 3;
+ eq = e / 3;
+ a = POW_MULL(a, pow_mult3[er]);
+ while (a >= 2 * POW_FRAC_ONE) {
+ a = a >> 1;
+ eq++;
+ }
+ /* convert to float */
+ while (a < POW_FRAC_ONE) {
+ a = a << 1;
+ eq--;
+ }
+ /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */
+#if POW_FRAC_BITS > FRAC_BITS
+ a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS);
+ /* correct overflow */
+ if (a >= 2 * (1 << FRAC_BITS)) {
+ a = a >> 1;
+ eq++;
+ }
+#endif
+ *exp_ptr = eq;
+ return a;
+}