From 7d15b22095ae63b655fe9076dd27334522d6b8ae Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 12:40:03 +0100 Subject: [PATCH 01/21] create files for division --- src/division.h | 8 ++++++++ src/divsion.c | 0 test/test_division.c | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/division.h create mode 100644 src/divsion.c create mode 100644 test/test_division.c diff --git a/src/division.h b/src/division.h new file mode 100644 index 0000000..89c53e8 --- /dev/null +++ b/src/division.h @@ -0,0 +1,8 @@ +// +// Created by Justin Trausch on 06.02.2024. +// + +#ifndef LINKES_TWIX_DIVISION_H +#define LINKES_TWIX_DIVISION_H + +#endif //LINKES_TWIX_DIVISION_H diff --git a/src/divsion.c b/src/divsion.c new file mode 100644 index 0000000..e69de29 diff --git a/test/test_division.c b/test/test_division.c new file mode 100644 index 0000000..253540e --- /dev/null +++ b/test/test_division.c @@ -0,0 +1,16 @@ +#ifdef TEST + +#include "unity.h" + +#include "exponent.h" +#include "logarithmus.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +#endif // TEST \ No newline at end of file From 282662d52911771bc2ce303c9ff597bf61852f69 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:30:07 +0100 Subject: [PATCH 02/21] Include headerfile --- src/divsion.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/divsion.c b/src/divsion.c index e69de29..6e22f11 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -0,0 +1 @@ +#include "division.h" \ No newline at end of file From 8e82d6adf21a940f9d901a01d506d3dff5581fc1 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:30:38 +0100 Subject: [PATCH 03/21] Basisstruktur division --- src/divsion.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/divsion.c b/src/divsion.c index 6e22f11..61014e0 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -1 +1,5 @@ -#include "division.h" \ No newline at end of file +#include "division.h" + +int divisionInt(int a, int b) { + return 0; +} \ No newline at end of file From 0d04a85521f305db675e381b9ccc0a037609983d Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:31:39 +0100 Subject: [PATCH 04/21] Basisstruktur Gleitkomma-Division --- src/divsion.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/divsion.c b/src/divsion.c index 61014e0..f02acc9 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -1,5 +1,10 @@ #include "division.h" int divisionInt(int a, int b) { + + return 0; +} + +double divisionDouble(double a, double b) { return 0; } \ No newline at end of file From dc184134ac2613bc3e6ad213ba3fefe3e96ca4be Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:33:12 +0100 Subject: [PATCH 05/21] Basisstruktur Division : 2 (Bitshift rechts) --- src/divsion.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/divsion.c b/src/divsion.c index f02acc9..6f7ea3f 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -1,10 +1,13 @@ #include "division.h" int divisionInt(int a, int b) { - return 0; } double divisionDouble(double a, double b) { return 0; -} \ No newline at end of file +} + +int divisionByTwo(int a, int b) { + return 0; +} From ab3c976bf48a441a1dc8c99f753f1a56d8e9d9dc Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:34:09 +0100 Subject: [PATCH 06/21] =?UTF-8?q?Hinzuf=C3=BCgen=20Funktionsdefinition=20H?= =?UTF-8?q?eaderfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/division.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/division.h b/src/division.h index 89c53e8..95715a0 100644 --- a/src/division.h +++ b/src/division.h @@ -5,4 +5,7 @@ #ifndef LINKES_TWIX_DIVISION_H #define LINKES_TWIX_DIVISION_H +int divisionInt(int a, int b); + + #endif //LINKES_TWIX_DIVISION_H From 00b6c8c87421fa239d5dd93d03bcb1d1e0888211 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:34:39 +0100 Subject: [PATCH 07/21] =?UTF-8?q?Hinzuf=C3=BCgen=20Funktionsdefinition=20H?= =?UTF-8?q?eaderfile=20Double=20Division?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/division.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/division.h b/src/division.h index 95715a0..c4b13fb 100644 --- a/src/division.h +++ b/src/division.h @@ -7,5 +7,8 @@ int divisionInt(int a, int b); +double divisionDouble(double a, double b); + + #endif //LINKES_TWIX_DIVISION_H From 07099b3f336917c5d4993fac15111bc863de9ac9 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:35:07 +0100 Subject: [PATCH 08/21] =?UTF-8?q?Hinzuf=C3=BCgen=20Funktionsdefinition=20H?= =?UTF-8?q?eaderfile=20Division=20by=20two?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/division.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/division.h b/src/division.h index c4b13fb..054648b 100644 --- a/src/division.h +++ b/src/division.h @@ -6,9 +6,8 @@ #define LINKES_TWIX_DIVISION_H int divisionInt(int a, int b); - double divisionDouble(double a, double b); - +int divisionByTwo(int a, int b); #endif //LINKES_TWIX_DIVISION_H From 2e4e77e8c0dccd1256cd6f41e63733e506353fba Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 16:23:38 +0100 Subject: [PATCH 09/21] Division Integer Struktur --- src/divsion.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/divsion.c b/src/divsion.c index 6f7ea3f..054eaf4 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -1,7 +1,12 @@ #include "division.h" int divisionInt(int a, int b) { - return 0; + if (b != 0) { + return a / b; + } + else { + return 0; + } } double divisionDouble(double a, double b) { From 24b707b24c6f00e86c8f865081606b89c6c35825 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 16:27:42 +0100 Subject: [PATCH 10/21] Division Double Struktur --- src/divsion.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/divsion.c b/src/divsion.c index 054eaf4..ab06fbf 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -10,7 +10,12 @@ int divisionInt(int a, int b) { } double divisionDouble(double a, double b) { - return 0; + if (b != 0) { + return a / b; + } + else { + return 0; + } } int divisionByTwo(int a, int b) { From 790254397918385d93f122edda69704089fce9f8 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 16:39:39 +0100 Subject: [PATCH 11/21] Division divisionbytwo Bitshift struktur --- src/divsion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/divsion.c b/src/divsion.c index ab06fbf..e4e06fb 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -19,5 +19,5 @@ double divisionDouble(double a, double b) { } int divisionByTwo(int a, int b) { - return 0; + return a >> b; } From a46a8a1df0e537e579593583d210e26be1341122 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 16:46:47 +0100 Subject: [PATCH 12/21] refactoring: Including von divisions headerfile --- test/test_division.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_division.c b/test/test_division.c index 253540e..650238f 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -2,8 +2,8 @@ #include "unity.h" -#include "exponent.h" -#include "logarithmus.h" +#include "division.h" + void setUp(void) { From 01e89603d278cbeb98afa0e70598e97cbdd485b0 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 17:08:29 +0100 Subject: [PATCH 13/21] Including von divsion.c --- test/test_division.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_division.c b/test/test_division.c index 650238f..3422430 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -3,7 +3,7 @@ #include "unity.h" #include "division.h" - +#include "divsion.c" void setUp(void) { From b29e78919027b139ce83ca23a83983a31632b992 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 17:10:14 +0100 Subject: [PATCH 14/21] test_divsion_1 von dem Fall 10 / 2 = 5 --- test/test_division.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_division.c b/test/test_division.c index 3422430..330359e 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -13,4 +13,14 @@ void tearDown(void) { } +void test_division_1(void) +{ + int result, expected = 5; + + result = divisionInt(10,2); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + + #endif // TEST \ No newline at end of file From e9468bd84aa0a4d860d63d40ddee936653023a0d Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 17:23:16 +0100 Subject: [PATCH 15/21] test_divsion_2. von dem Fall 10 / 2 = 5 --- test/test_division.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_division.c b/test/test_division.c index 330359e..8eb9e41 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -22,5 +22,13 @@ void test_division_1(void) TEST_ASSERT_EQUAL_INT(expected, result); } +void test_division_2(void) +{ + double result, expected = 5.0; + + result = divisionDouble(10.0,2.0); + + TEST_ASSERT_EQUAL_INT(expected, result); +} #endif // TEST \ No newline at end of file From a6e9756d27d5bfbe6def14625b7217807d534d9a Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 17:37:02 +0100 Subject: [PATCH 16/21] test_divsion_3. bitshift von 16 und 2 --- test/test_division.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test_division.c b/test/test_division.c index 8eb9e41..c128f06 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -31,4 +31,13 @@ void test_division_2(void) TEST_ASSERT_EQUAL_INT(expected, result); } +void test_division_3(void) +{ + int result, expected = 4; + + result = divisionByTwo(16,2); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + #endif // TEST \ No newline at end of file From 857594bfa9eda74794dfd9c38739ece6e044ce63 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 20:47:12 +0100 Subject: [PATCH 17/21] =?UTF-8?q?refactoring:=20test=20von=20int=20auf=20d?= =?UTF-8?q?ouble=20umge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_division.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_division.c b/test/test_division.c index c128f06..52b1036 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -28,7 +28,7 @@ void test_division_2(void) result = divisionDouble(10.0,2.0); - TEST_ASSERT_EQUAL_INT(expected, result); + TEST_ASSERT_EQUAL_DOUBLE(expected, result); } void test_division_3(void) From d0407f5726161f5787768264e740d55a4da342d7 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:17:53 +0100 Subject: [PATCH 18/21] =?UTF-8?q?Beim=20bitshift=20erg=C3=A4nzt=20falls=20?= =?UTF-8?q?der=20Fall=20eintreten=20w=C3=BCrde=20das=20der=20Exponnent=200?= =?UTF-8?q?=20w=C3=A4re?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/divsion.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/divsion.c b/src/divsion.c index e4e06fb..5f1dcbd 100644 --- a/src/divsion.c +++ b/src/divsion.c @@ -19,5 +19,8 @@ double divisionDouble(double a, double b) { } int divisionByTwo(int a, int b) { + if (b == 0){ + return a; +} return a >> b; } From 08d3d60566bbf8aa42ab1e5f5d4a218343543f94 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:21:46 +0100 Subject: [PATCH 19/21] test_bitshift_druch_0 bei bitshift funktion --- test/test_division.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test_division.c b/test/test_division.c index 52b1036..4ecb4dc 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -31,6 +31,15 @@ void test_division_2(void) TEST_ASSERT_EQUAL_DOUBLE(expected, result); } +void test_bitshiftdruch0(void) +{ + int result, expected = 16; + + result = divisionByTwo(16,0); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + void test_division_3(void) { int result, expected = 4; From db1ea053ca30e72b0bfdbffa06295e8574a6996d Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:24:56 +0100 Subject: [PATCH 20/21] test_division_1_durch_0 mit Int Division --- test/test_division.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test_division.c b/test/test_division.c index 4ecb4dc..8fd5bbc 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -22,6 +22,15 @@ void test_division_1(void) TEST_ASSERT_EQUAL_INT(expected, result); } +void test_division_1_durch_0(void) +{ + int result, expected = 0; + + result = divisionInt(10,0); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + void test_division_2(void) { double result, expected = 5.0; From ab74143d71cd97df0269dba3b76d6a51ca55ffda Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:26:48 +0100 Subject: [PATCH 21/21] refactoring: beschreibung des Tests angepasst --- test/test_division.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_division.c b/test/test_division.c index 8fd5bbc..ccf59c7 100644 --- a/test/test_division.c +++ b/test/test_division.c @@ -40,7 +40,7 @@ void test_division_2(void) TEST_ASSERT_EQUAL_DOUBLE(expected, result); } -void test_bitshiftdruch0(void) +void test_bitshift_druch_0(void) { int result, expected = 16;