|
@ -6,10 +6,12 @@ |
|
|
|
|
|
|
|
|
num carry[1]; |
|
|
num carry[1]; |
|
|
|
|
|
|
|
|
|
|
|
unsigned int e = 8388608; |
|
|
|
|
|
|
|
|
union { |
|
|
union { |
|
|
float floating; |
|
|
float floating; |
|
|
unsigned int integer; |
|
|
unsigned int integer; |
|
|
} number[5]; |
|
|
|
|
|
|
|
|
} number[6]; |
|
|
|
|
|
|
|
|
void setUp(void) |
|
|
void setUp(void) |
|
|
{ |
|
|
{ |
|
@ -189,6 +191,26 @@ void test_addition_exponentfloatingnumber(void) |
|
|
TEST_ASSERT_EQUAL_UINT(expected[4], result[4]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[4], result[4]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_addition_addition_precision_positivnumberlowerthan2tothepowerof24(void) |
|
|
|
|
|
{ |
|
|
|
|
|
unsigned int result[2]; |
|
|
|
|
|
number[0].floating = 652468761.2348, number[1].floating = 2.675312546943, number[2].floating = 321647956212.2146, number[3].floating = 0.00000324567861, number[4].floating = number[0].floating + number[1].floating; number[5].floating = number[2].floating + number[3].floating; |
|
|
|
|
|
unsigned int expected[2] = { precision(number[4].integer), precision(number[5].integer) }; |
|
|
|
|
|
|
|
|
|
|
|
unsigned int e0, e1, e2, e3, p0, p1, p2, p3; |
|
|
|
|
|
|
|
|
|
|
|
e0 = exponent(number[0].integer), e1 = exponent(number[1].integer), e2 = exponent(number[2].integer), e3 = exponent(number[3].integer); |
|
|
|
|
|
p0 = precision(number[0].integer) | e, p1 = precision(number[1].integer) | e, p2 = precision(number[2].integer) | e, p3 = precision(number[3].integer) | e; |
|
|
|
|
|
|
|
|
|
|
|
p1 >>= e0 - e1, p3 >>= e2 - e3; |
|
|
|
|
|
|
|
|
|
|
|
result[0] = addition_precision( p0, p1 ) ^ e; |
|
|
|
|
|
result[1] = addition_precision( p2, p3 ) ^ e; |
|
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void test_addition_output_numberwithsignexponentprecision(void) |
|
|
void test_addition_output_numberwithsignexponentprecision(void) |
|
|
{ |
|
|
{ |
|
|
unsigned int result[5]; |
|
|
unsigned int result[5]; |
|
|