From 931d213d4395c6d0ef93f30fe606da8ee3baa6d2 Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Mon, 29 Apr 2024 02:14:56 +0200
Subject: [PATCH] update permutation
---
python-grundlage/find-machinell-epsilon.py | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/python-grundlage/find-machinell-epsilon.py b/python-grundlage/find-machinell-epsilon.py
index 4fd47a5..9505c55 100644
--- a/python-grundlage/find-machinell-epsilon.py
+++ b/python-grundlage/find-machinell-epsilon.py
@@ -1,13 +1,19 @@
-# Credit: https://stackoverflow.com/a/57579379
-
import sys
-eps = 1.0
-while eps + 1 > 1:
- eps /= 2
-eps *= 2
sys_eps = sys.float_info.epsilon
+
+eps = 1.0
+while 1.0 + eps > 1.0:
+ eps /= 2.0
+eps *= 2.0
+
print(f"The calculated epsilon: {eps}")
print(f" The system epsilon: {sys_eps}")
+# with assign expression
+eps = 1.0
+while 1.0 + (eps := eps / 2.0) > 1.0: pass
+eps *= 2.0
+print(f"The calculated epsilon: {eps}")
+print(f" The system epsilon: {sys_eps}")
--
Gitblit v1.10.0