diff --git a/src/addition.h b/src/addition.h index 86dd0a4..9382434 100644 --- a/src/addition.h +++ b/src/addition.h @@ -13,6 +13,8 @@ unsigned int precision(unsigned int number); unsigned int e(unsigned int a); +unsigned int o(unsigned int s, unsigned int e, unsigned int p); + float addition_float(float number1, float number2); #endif // ADDITION_H \ No newline at end of file diff --git a/test/test_addition.c b/test/test_addition.c index 5bcf631..bc70b6d 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -189,6 +189,30 @@ void test_addition_exponentfloatingnumber(void) TEST_ASSERT_EQUAL_UINT(expected[4], result[4]); } +void test_addition_output_numberwithsignexponentprecision(void) +{ + unsigned int result[5]; + number[0].floating = 1468921, number[1].floating = -32468127698, number[2].floating = 0.000000795311468, number[3].floating = -0.00000843214521, number[4].floating = 14; + unsigned int expected[5] = { number[0].integer, number[1].integer, number[2].integer, number[3].integer, number[4].integer }; + + unsigned int s0, s1, s2, s3, s4, e0, e1, e2, e3, e4, p0, p1, p2, p3, p4; + + s0 = sign(number[0].integer), s1 = sign(number[1].integer), s2 = sign(number[2].integer), s3 = sign(number[3].integer), s4 = sign(number[4].integer); + e0 = e(number[0].integer), e1 = e(number[1].integer), e2 = e(number[2].integer), e3 = e(number[3].integer), e4 = e(number[4].integer); + p0 = precision(number[0].integer), p1 = precision(number[1].integer), p2 = precision(number[2].integer), p3 = precision(number[3].integer), p4 = precision(number[4].integer); + result[0] = o(s0, e0, p0); + result[1] = o(s1, e1, p1); + result[2] = o(s2, e2, p2); + result[3] = o(s3, e3, p3); + result[4] = o(s4, e4, p4); + + TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); + TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); + TEST_ASSERT_EQUAL_UINT(expected[2], result[2]); + TEST_ASSERT_EQUAL_UINT(expected[3], result[3]); + TEST_ASSERT_EQUAL_UINT(expected[4], result[4]); +} + void test_addition_addition_float_0plus0gleich0(void) { float result;