summaryrefslogtreecommitdiff
path: root/source/luametatex/source/mp
diff options
context:
space:
mode:
Diffstat (limited to 'source/luametatex/source/mp')
-rw-r--r--source/luametatex/source/mp/mpc/mpmath.c34
-rw-r--r--source/luametatex/source/mp/mpw/mpmath.w34
-rw-r--r--source/luametatex/source/mp/mpw/mpmathdouble.w2
-rw-r--r--source/luametatex/source/mp/readme.txt26
4 files changed, 48 insertions, 48 deletions
diff --git a/source/luametatex/source/mp/mpc/mpmath.c b/source/luametatex/source/mp/mpc/mpmath.c
index 0a848b23e..d58d4f00f 100644
--- a/source/luametatex/source/mp/mpc/mpmath.c
+++ b/source/luametatex/source/mp/mpc/mpmath.c
@@ -5,7 +5,7 @@
# include "mpmath.h"
# include "mpstrings.h"
-# define coef_bound 04525252525
+# define coef_bound 0x25555555
# define fraction_threshold 2685
# define half_fraction_threshold 1342
# define scaled_threshold 8
@@ -18,9 +18,9 @@
# define three (3*unity)
# define half_unit (unity/2)
# define three_quarter_unit (3*(unity/4))
-# define EL_GORDO 0x7fffffff
+# define EL_GORDO 0x7FFFFFFF
# define negative_EL_GORDO (-EL_GORDO)
-# define one_third_EL_GORDO 05252525252
+# define one_third_EL_GORDO 0x2AAAAAAA
# define TWEXP31 2147483648.0
# define TWEXP28 268435456.0
# define TWEXP16 65536.0
@@ -602,7 +602,7 @@ static char *mp_string_scaled (MP mp, int s)
scaled_string[i++] = '.';
do {
if (delta > unity) {
- s = s + 0100000 - (delta / 2);
+ s = s + 0x8000 - (delta / 2);
}
scaled_string[i++] = '0' + (s / unity);
s = 10 * (s % unity);
@@ -646,7 +646,7 @@ static int mp_make_fraction (MP mp, int p, int q)
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? -q : q) & 077777) * (((i & 037777) << 1) - 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? -q : q) & 0x7FFF) * (((i & 0x3FFF) << 1) - 1) & 0x800) != 0) {
--i;
}
return i;
@@ -658,7 +658,7 @@ static int mp_make_fraction (MP mp, int p, int q)
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? q : -q) & 077777) * (((i & 037777) << 1) + 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? q : -q) & 0x7FFF) * (((i & 0x3FFF) << 1) + 1) & 0x800) != 0) {
++i;
}
return i;
@@ -678,13 +678,13 @@ int mp_take_fraction (MP mp, int p, int q)
if ((p ^ q) >= 0) {
d += 0.5;
if (d >= TWEXP31) {
- if (d != TWEXP31 || (((p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != TWEXP31 || (((p & 0x7FFF) * (q & 0x7FFF)) & 040000) == 0) {
mp->arith_error = 1;
}
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && (((p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
--i;
}
return i;
@@ -692,13 +692,13 @@ int mp_take_fraction (MP mp, int p, int q)
} else {
d -= 0.5;
if (d <= -TWEXP31) {
- if (d != -TWEXP31 || ((-(p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != -TWEXP31 || ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) == 0) {
mp->arith_error = 1;
}
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && ((-(p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
++i;
}
return i;
@@ -717,13 +717,13 @@ static int mp_take_scaled (MP mp, int p, int q)
if ((p ^ q) >= 0) {
d += 0.5;
if (d >= TWEXP31) {
- if (d != TWEXP31 || (((p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != TWEXP31 || (((p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) == 0) {
mp->arith_error = 1;
}
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && (((p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
--i;
}
return i;
@@ -731,13 +731,13 @@ static int mp_take_scaled (MP mp, int p, int q)
} else {
d -= 0.5;
if (d <= -TWEXP31) {
- if (d != -TWEXP31 || ((-(p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != -TWEXP31 || ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) == 0) {
mp->arith_error = 1;
}
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && ((-(p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
++i;
}
return i;
@@ -764,7 +764,7 @@ int mp_make_scaled (MP mp, int p, int q)
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? -q : q) & 077777) * (((i & 037777) << 1) - 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? -q : q) & 0x7FFF) * (((i & 0x3FFF) << 1) - 1) & 0x800) != 0) {
--i;
}
return i;
@@ -776,7 +776,7 @@ int mp_make_scaled (MP mp, int p, int q)
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? q : -q) & 077777) * (((i & 037777) << 1) + 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? q : -q) & 0x7FFF) * (((i & 0x3FFF) << 1) + 1) & 0x800) != 0) {
++i;
}
return i;
@@ -1239,7 +1239,7 @@ void mp_m_exp (MP mp, mp_number *ret, mp_number *x_orig)
} else {
if (x <= 0) {
z = -8 * x;
- y = 04000000;
+ y = 0x100000;
} else {
if (x <= 127919879) {
z = 1023359037 - 8 * x;
diff --git a/source/luametatex/source/mp/mpw/mpmath.w b/source/luametatex/source/mp/mpw/mpmath.w
index 5e9592fc7..7b43da72b 100644
--- a/source/luametatex/source/mp/mpw/mpmath.w
+++ b/source/luametatex/source/mp/mpw/mpmath.w
@@ -107,7 +107,7 @@ static char *mp_number_tostring (MP mp, mp_number *n);
static char *mp_string_scaled (MP mp, int s);
@
-@d coef_bound 04525252525 /* |fraction| approximation to 7/3 */
+@d coef_bound 0x25555555 /* |fraction| approximation to 7/3 */ /* 04525252525 */
@d fraction_threshold 2685 /* a |fraction| coefficient less than this is zeroed */
@d half_fraction_threshold 1342 /* half of |fraction_threshold| */
@d scaled_threshold 8 /* a |scaled| coefficient less than this is zeroed */
@@ -125,9 +125,9 @@ from the right end of a binary computer word.
@d three (3*unity) /* $2^{17}+2^{16}$, represents 3.00000 */
@d half_unit (unity/2) /* $2^{15}$, represents 0.50000 */
@d three_quarter_unit (3*(unity/4)) /* $3\cdot2^{14}$, represents 0.75000 */
-@d EL_GORDO 0x7fffffff /* $2^{31}-1$, the largest value that \MP\ likes */
+@d EL_GORDO 0x7FFFFFFF /* $2^{31}-1$, the largest value that \MP\ likes */
@d negative_EL_GORDO (-EL_GORDO)
-@d one_third_EL_GORDO 05252525252
+@d one_third_EL_GORDO 0x2AAAAAAA /* 05252525252 */
@ We need these preprocessor values
@@ -685,7 +685,7 @@ static char *mp_string_scaled (MP mp, int s)
do {
/* round the final digit */
if (delta > unity) {
- s = s + 0100000 - (delta / 2);
+ s = s + 0x8000 - (delta / 2);
}
scaled_string[i++] = '0' + (s / unity);
s = 10 * (s % unity);
@@ -769,7 +769,7 @@ static int mp_make_fraction (MP mp, int p, int q)
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? -q : q) & 077777) * (((i & 037777) << 1) - 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? -q : q) & 0x7FFF) * (((i & 0x3FFF) << 1) - 1) & 0x800) != 0) {
--i;
}
return i;
@@ -781,7 +781,7 @@ static int mp_make_fraction (MP mp, int p, int q)
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? q : -q) & 077777) * (((i & 037777) << 1) + 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? q : -q) & 0x7FFF) * (((i & 0x3FFF) << 1) + 1) & 0x800) != 0) {
++i;
}
return i;
@@ -811,13 +811,13 @@ int mp_take_fraction (MP mp, int p, int q)
if ((p ^ q) >= 0) {
d += 0.5;
if (d >= TWEXP31) {
- if (d != TWEXP31 || (((p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != TWEXP31 || (((p & 0x7FFF) * (q & 0x7FFF)) & 040000) == 0) {
mp->arith_error = 1;
}
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && (((p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
--i;
}
return i;
@@ -825,13 +825,13 @@ int mp_take_fraction (MP mp, int p, int q)
} else {
d -= 0.5;
if (d <= -TWEXP31) {
- if (d != -TWEXP31 || ((-(p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != -TWEXP31 || ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) == 0) {
mp->arith_error = 1;
}
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && ((-(p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
++i;
}
return i;
@@ -860,13 +860,13 @@ static int mp_take_scaled (MP mp, int p, int q)
if ((p ^ q) >= 0) {
d += 0.5;
if (d >= TWEXP31) {
- if (d != TWEXP31 || (((p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != TWEXP31 || (((p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) == 0) {
mp->arith_error = 1;
}
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && (((p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
--i;
}
return i;
@@ -874,13 +874,13 @@ static int mp_take_scaled (MP mp, int p, int q)
} else {
d -= 0.5;
if (d <= -TWEXP31) {
- if (d != -TWEXP31 || ((-(p & 077777) * (q & 077777)) & 040000) == 0) {
+ if (d != -TWEXP31 || ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) == 0) {
mp->arith_error = 1;
}
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && ((-(p & 077777) * (q & 077777)) & 040000) != 0) {
+ if (d == (double) i && ((-(p & 0x7FFF) * (q & 0x7FFF)) & 0x4000) != 0) {
++i;
}
return i;
@@ -914,7 +914,7 @@ int mp_make_scaled (MP mp, int p, int q)
return EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? -q : q) & 077777) * (((i & 037777) << 1) - 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? -q : q) & 0x7FFF) * (((i & 0x3FFF) << 1) - 1) & 0x800) != 0) {
--i;
}
return i;
@@ -926,7 +926,7 @@ int mp_make_scaled (MP mp, int p, int q)
return -negative_EL_GORDO;
} else {
int i = (int) d;
- if (d == (double) i && (((q > 0 ? q : -q) & 077777) * (((i & 037777) << 1) + 1) & 04000) != 0) {
+ if (d == (double) i && (((q > 0 ? q : -q) & 0x7FFF) * (((i & 0x3FFF) << 1) + 1) & 0x800) != 0) {
++i;
}
return i;
@@ -1575,7 +1575,7 @@ void mp_m_exp (MP mp, mp_number *ret, mp_number *x_orig)
} else {
if (x <= 0) {
z = -8 * x;
- y = 04000000; /* $y=2^{20}$ */
+ y = 0x100000; /* $y=2^{20}$ */
} else {
if (x <= 127919879) {
z = 1023359037 - 8 * x;
diff --git a/source/luametatex/source/mp/mpw/mpmathdouble.w b/source/luametatex/source/mp/mpw/mpmathdouble.w
index f5a91df75..c836fc4bb 100644
--- a/source/luametatex/source/mp/mpw/mpmathdouble.w
+++ b/source/luametatex/source/mp/mpw/mpmathdouble.w
@@ -23,7 +23,7 @@ math_data *mp_initialize_double_math (MP mp);
@* Math initialization.
-First, here are some very important constants.
+First, here are some very important constants. We can have some more (see velocity).
@d PI 3.1415926535897932384626433832795028841971
@d fraction_multiplier 4096.0
diff --git a/source/luametatex/source/mp/readme.txt b/source/luametatex/source/mp/readme.txt
index c48e19a89..bb98005de 100644
--- a/source/luametatex/source/mp/readme.txt
+++ b/source/luametatex/source/mp/readme.txt
@@ -1,14 +1,14 @@
-Remark
-
-When a CWEB file is adapted we need to convert to C. This is normally done with the tangle
-program but as we want to be independent of other tools (which themselves can result in a
-chain of dependencies) we use a Lua script which happens to be run with LuaMetaTeX.
-
-Of course there is a chicken egg issue here but at some point we started with C files so
-now we only need to update.
-
-The script is located in the "tools" path alongside the "source" path and it is run in its
-own directory (which for me means: hit the run key when the document is open). As we always
-ship the C files, there is no need for a user to run the script.
-
+Remark
+
+When a CWEB file is adapted we need to convert to C. This is normally done with the tangle
+program but as we want to be independent of other tools (which themselves can result in a
+chain of dependencies) we use a Lua script which happens to be run with LuaMetaTeX.
+
+Of course there is a chicken egg issue here but at some point we started with C files so
+now we only need to update.
+
+The script is located in the "tools" path alongside the "source" path and it is run in its
+own directory (which for me means: hit the run key when the document is open). As we always
+ship the C files, there is no need for a user to run the script.
+
Hans Hagen \ No newline at end of file