#include "scaf.h"
+/*----- Debugging utilties ------------------------------------------------*/
+
+#ifdef SCAF_DEBUG
+
+#include <stdio.h>
+
+#include "mp.h"
+#include "mpint.h"
+#include "mptext.h"
+
+static void scaf_dump(const char *what, const scaf_piece *x,
+ size_t npiece, size_t piecewd)
+{
+ mp *y = MP_ZERO, *t = MP_NEW;
+ size_t i;
+ unsigned o = 0;
+
+ for (i = 0; i < npiece; i++) {
+ t = mp_fromuint64(t, x[i]);
+ t = mp_lsl(t, t, o);
+ y = mp_add(y, y, t);
+ o += piecewd;
+ }
+ printf(";; %s", what); MP_PRINT("", y); putchar('\n');
+ mp_drop(y); mp_drop(t);
+}
+
+static void scaf_dumpdbl(const char *what, const scaf_dblpiece *x,
+ size_t npiece, size_t piecewd)
+{
+ mp *y = MP_ZERO, *t = MP_NEW;
+ size_t i;
+ unsigned o = 0;
+
+ for (i = 0; i < npiece; i++) {
+ t = mp_fromuint64(t, x[i]);
+ t = mp_lsl(t, t, o);
+ y = mp_add(y, y, t);
+ o += piecewd;
+ }
+ printf(";; %s", what); MP_PRINT("", y); putchar('\n');
+ mp_drop(y); mp_drop(t);
+}
+
+#endif
+
/*----- Main code ---------------------------------------------------------*/
/* --- @scaf_load@ --- *
* @const scaf_piece *mu@ = scaled approximation to @1/l@
* @size_t npiece@ = number of pieces in @l@
* @unsigned piecewd@ = nominal width of a piece in bits
- * @scaf_piece *scratch@ = @3*npiece + 1@ scratch pieces
+ * @scaf_piece *scratch@ = @3*npiece@ scratch pieces
*
* Returns: ---
*
/* This here is the hard part.
*
- * Let w = PIECEWD, let n = NPIECE, and let B = 2^w. Wwe must have
+ * Let w = PIECEWD, let n = NPIECE, and let B = 2^w. We must have
* B^(n-1) <= l < B^n.
*
* The argument MU contains pieces of the quantity ยต = floor(B^2n/l), which