From b2186d6019530f80b807b6ffedb1e137c7adb3e0 Mon Sep 17 00:00:00 2001 From: Loosen-IT Date: Fri, 1 Mar 2024 12:32:09 +0100 Subject: [PATCH] 01/03/2024 --- .idea/UNI_Python.iml | 2 +- .idea/misc.xml | 2 +- _pruefung/examples.py | 16 ++++++++++++++++ ext_02/test.cpp | 19 +++++++++++++++++++ ext_02/test.py | 14 ++++++++++++++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 _pruefung/examples.py create mode 100644 ext_02/test.cpp create mode 100644 ext_02/test.py diff --git a/.idea/UNI_Python.iml b/.idea/UNI_Python.iml index 5854a2f..adf23df 100644 --- a/.idea/UNI_Python.iml +++ b/.idea/UNI_Python.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index c20271c..59b5b2e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/_pruefung/examples.py b/_pruefung/examples.py new file mode 100644 index 0000000..69e3131 --- /dev/null +++ b/_pruefung/examples.py @@ -0,0 +1,16 @@ +import sys + + +def greet(name): + print(f"Hello {name}") + +def greet(name, message): + print(f"Hello {name}, {message}.") + +try: + greet("Jan") + greet("Jan", "Wie gehts?") +except Exception as e: + print(e) + +print(sys.float_info.epsilon) \ No newline at end of file diff --git a/ext_02/test.cpp b/ext_02/test.cpp new file mode 100644 index 0000000..a1ffdbb --- /dev/null +++ b/ext_02/test.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +namespace mp = boost::multiprecision; + +mp::cpp_dec_float_1000 calc(const mp::cpp_dec_float_1000& const_value) { + mp::cpp_dec_float_1000 sum = 0; + for (int k = 1; k <= 10000; ++k) { + sum += pow(const_value, k) / boost::math::factorial(k); + } + return sum; +} + +int main() { + mp::cpp_dec_float_1000 result = calc(log(mp::cpp_dec_float_1000(2)); + std::cout << result << std::endl; + return 0; +} \ No newline at end of file diff --git a/ext_02/test.py b/ext_02/test.py new file mode 100644 index 0000000..05b8c4c --- /dev/null +++ b/ext_02/test.py @@ -0,0 +1,14 @@ +import math +from decimal import Decimal, getcontext + +__author__ = "Jan-Niclas Loosen" + + +def calc(const): + summe = Decimal(0) + for k in range(1, 100): + summe += (Decimal(const) ** k) / math.factorial(k) + return summe + +getcontext().prec = 1000 # Set the precision for Decimal calculations +print(calc(math.log(2)))