diff --git a/src/addition.c b/src/addition.c index c7963bd..fd74c3e 100644 --- a/src/addition.c +++ b/src/addition.c @@ -43,15 +43,15 @@ unsigned int precision(unsigned int number) { // reading exponent out of an integer (floating number) -unsigned int e(unsigned int a) { - unsigned int e = 2139095040; - return (a & e) >> 23; +unsigned int exponent(unsigned int number) { + unsigned int exponent = 2139095040; + return (number & exponent) >> 23; } // writing number out of sign, exponent and precision -unsigned int o(unsigned int s, unsigned int e, unsigned int p) { - return (s << 31) | (e << 23) | p; +unsigned int output(unsigned int sign, unsigned int exponent, unsigned int precision) { + return (sign << 31) | (exponent << 23) | precision; } // addition of two floating numbers diff --git a/src/addition.h b/src/addition.h index 9382434..2d2878f 100644 --- a/src/addition.h +++ b/src/addition.h @@ -11,9 +11,9 @@ unsigned int sign(unsigned int number); unsigned int precision(unsigned int number); -unsigned int e(unsigned int a); +unsigned int exponent(unsigned int number); -unsigned int o(unsigned int s, unsigned int e, unsigned int p); +unsigned int output(unsigned int sign, unsigned int exponent, unsigned int precision); float addition_float(float number1, float number2); diff --git a/test/test_addition.c b/test/test_addition.c index bc70b6d..e7ff443 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -176,11 +176,11 @@ void test_addition_exponentfloatingnumber(void) number[0].floating = 0, number[1].floating = -762134982, number[2].floating = 47621349, number[3].floating = -0.0000078961354, number[4].floating = 0.00001568943; unsigned int expected[5] = { ( number[0].integer << 1) >> 24 , ( number[1].integer << 1) >> 24, ( number[2].integer << 1) >> 24, ( number[3].integer << 1) >> 24, ( number[4].integer << 1) >> 24}; - result[0] = e( number[0].integer ); - result[1] = e( number[1].integer ); - result[2] = e( number[2].integer ); - result[3] = e( number[3].integer ); - result[4] = e( number[4].integer ); + result[0] = exponent( number[0].integer ); + result[1] = exponent( number[1].integer ); + result[2] = exponent( number[2].integer ); + result[3] = exponent( number[3].integer ); + result[4] = exponent( number[4].integer ); TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); @@ -198,13 +198,13 @@ void test_addition_output_numberwithsignexponentprecision(void) 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); + e0 = exponent(number[0].integer), e1 = exponent(number[1].integer), e2 = exponent(number[2].integer), e3 = exponent(number[3].integer), e4 = exponent(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); + result[0] = output(s0, e0, p0); + result[1] = output(s1, e1, p1); + result[2] = output(s2, e2, p2); + result[3] = output(s3, e3, p3); + result[4] = output(s4, e4, p4); TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); TEST_ASSERT_EQUAL_UINT(expected[1], result[1]);