From 978a20ee7c4dfbaec3d3dadff832c91a85821d8e Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Mon, 5 Feb 2024 13:32:24 +0100 Subject: [PATCH] addition read exponent of a floating number --- src/addition.c | 7 +++++++ src/addition.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/addition.c b/src/addition.c index 724dd99..6afc239 100644 --- a/src/addition.c +++ b/src/addition.c @@ -41,6 +41,13 @@ unsigned int precision(unsigned int number) { return (number & precision); } +// reading exponent out of an integer (floating number) + +unsigned int e(unsigned int a) { + unsigned int e = 2139095040; + return (a & e) >> 23; +} + // addition of two floating numbers float addition_float(float number1, float number2) { diff --git a/src/addition.h b/src/addition.h index cf09c60..86dd0a4 100644 --- a/src/addition.h +++ b/src/addition.h @@ -11,6 +11,8 @@ unsigned int sign(unsigned int number); unsigned int precision(unsigned int number); +unsigned int e(unsigned int a); + float addition_float(float number1, float number2); -#endif // ADDITION_H +#endif // ADDITION_H \ No newline at end of file