summaryrefslogtreecommitdiffstats
path: root/pbn_div.c
diff options
context:
space:
mode:
Diffstat (limited to 'pbn_div.c')
-rw-r--r--pbn_div.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/pbn_div.c b/pbn_div.c
new file mode 100644
index 0000000..6c169ac
--- /dev/null
+++ b/pbn_div.c
@@ -0,0 +1,37 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2007 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, Inc.,
+ * 59 Temple Place Ste 330, Boston MA 02111-1307, USA; version 2.1,
+ * incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * pbn_div.c
+ */
+
+/* quotient, remainder, numerator, denominator
+
+ The sign on the outputs = sign(numerator) XOR sign(denominator)
+
+ Returns -1 on error (divide by zero) and frees the inputs */
+
+#include "pbn.h"
+
+int pbn_div(struct pbn **q, struct pbn **r, struct pbn *n, struct pbn *d)
+{
+ if (d->bits == 0) {
+ pbn_free(n);
+ pbn_free(d);
+ return -1; /* Division by zero */
+ }
+
+
+
+
+}
+