Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision e25ef8c9bc1cec34146129133c0654aaa9d5c268)
+++ libcfa/src/Makefile.am	(revision 108b2c75260d5b15cab02e847700d0ca68637ebe)
@@ -47,5 +47,4 @@
 	gmp.hfa \
 	math.trait.hfa \
-	math.hfa \
 	raii.hfa \
 	time_t.hfa \
@@ -81,4 +80,5 @@
 	iterator.hfa \
 	limits.hfa \
+	math.hfa \
 	memory.hfa \
 	parseargs.hfa \
Index: libcfa/src/math.cfa
===================================================================
--- libcfa/src/math.cfa	(revision 108b2c75260d5b15cab02e847700d0ca68637ebe)
+++ libcfa/src/math.cfa	(revision 108b2c75260d5b15cab02e847700d0ca68637ebe)
@@ -0,0 +1,57 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// math.cpp --
+//
+// Author           : Andrew Beach
+// Created On       : Mon Nov 25 16:20:00 2024
+// Last Modified By : Andrew Beach
+// Created On       : Mon Nov 27 15:11:00 2024
+// Update Count     : 0
+//
+
+#include "math.hfa"
+
+#include <limits.h>
+
+#pragma GCC visibility push(default)
+
+// Implementation of power functions (from the prelude):
+
+#define __CFA_EXP__() \
+	if ( y == 0 ) return 1;                             /* convention */ \
+	__CFA_EXP_INT__(                                    /* special cases for integral types */ \
+		if ( x == 1 ) return 1;                         /* base case */ \
+		if ( x == 2 ) return x << (y - 1);              /* positive shifting */ \
+		if ( y >= sizeof(y) * CHAR_BIT ) return 0;      /* immediate overflow, negative exponent > 2^size-1 */ \
+	) \
+	typeof(x) op = 1;                                   /* accumulate odd product */ \
+	typeof(x) w = x; /* FIX-ME: possible bug in the box pass changing value argument through parameter */ \
+	for ( ; y > 1; y >>= 1 ) {                          /* squaring exponentiation, O(log2 y) */ \
+		if ( (y & 1) == 1 ) op = op * w;                /* odd ? */ \
+		w = w * w; \
+	} \
+	return w * op
+#define __CFA_EXP_INT__(...) __VA_ARGS__
+
+int ?\?( int x, unsigned int y ) { __CFA_EXP__(); }
+long int ?\?( long int x, unsigned long int y ) { __CFA_EXP__(); }
+long long int ?\?( long long int x, unsigned long long int y ) { __CFA_EXP__(); }
+unsigned int ?\?( unsigned int x, unsigned int y ) { __CFA_EXP__(); }
+unsigned long int ?\?( unsigned long int x, unsigned long int y ) { __CFA_EXP__(); }
+unsigned long long int ?\?( unsigned long long int x, unsigned long long int y ) { __CFA_EXP__(); }
+
+#undef __CFA_EXP_INT__
+#define __CFA_EXP_INT__(...)
+
+forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {
+	OT ?\?( OT x, unsigned int y ) { __CFA_EXP__(); }
+	OT ?\?( OT x, unsigned long int y ) { __CFA_EXP__(); }
+	OT ?\?( OT x, unsigned long long int y ) { __CFA_EXP__(); }
+} // distribution
+
+#undef __CFA_EXP_INT__
+#undef __CFA_EXP__
