From 43f06890e2689af2ef54c4480fe5790692a24f65 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 11 Oct 2023 10:04:04 -0600 Subject: deprecate common lisp solutions and write c; it's too much effort to keep up with the requirements for an archive. --- src/maceps.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/maceps.c (limited to 'src/maceps.c') diff --git a/src/maceps.c b/src/maceps.c new file mode 100644 index 0000000..23bc9db --- /dev/null +++ b/src/maceps.c @@ -0,0 +1,28 @@ +#include "lizfcm.h" +#include + +float smaceps() { + float one = 1.0; + float machine_epsilon = 1.0; + float one_approx = one + machine_epsilon; + + while (fabsf(one_approx - one) > 0) { + machine_epsilon /= 2; + one_approx = one + machine_epsilon; + } + + return machine_epsilon; +} + +double dmaceps() { + double one = 1.0; + double machine_epsilon = 1.0; + double one_approx = one + machine_epsilon; + + while (fabs(one_approx - one) > 0) { + machine_epsilon /= 2; + one_approx = one + machine_epsilon; + } + + return machine_epsilon; +} -- cgit v1.2.3-70-g09d2