From 78307a0c6b92a34b4656b0172aacb3ccb813e067 Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Mon, 5 Feb 2024 13:33:14 +0100 Subject: [PATCH] testing: addition read exponent of a floating number --- test/test_addition.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_addition.c b/test/test_addition.c index 2f68711..a6e7e7d 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -168,6 +168,24 @@ void test_addition_precisionfloatingnumber(void) { TEST_ASSERT_EQUAL_UINT(expected[4], result[4]); } +void test_addition_exponentfloatingnumber(void) { + unsigned int result[5]; + 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 ); + + 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; float expected = (float) 0.0;