From 8043dce84fba36ab7695c80203bb8320544dc0ef Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Wed, 7 Feb 2024 11:10:30 +0100 Subject: [PATCH] addition reading exponent out of double numbers --- src/addition.c | 11 +++++++++++ src/addition.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/addition.c b/src/addition.c index 2db8d35..6b17097 100644 --- a/src/addition.c +++ b/src/addition.c @@ -111,11 +111,22 @@ float addition_float(float number1, float number2) { return num3.number.floating; } +// reading sign out of an integer (double number) + unsigned long long sign_double(unsigned long long a) { if (a & 0x8000000000000000) return 1; else return 0; } +// reading precision out of an integer (double number) + unsigned long long precision_double(unsigned long long a) { return a & 0x000fffffffffffff; +} + +// reading exponent out of an integer (double number) + +unsigned long long exponent_double(unsigned long long number) { + unsigned long long exponent = 0x7ff0000000000000; + return (number & exponent) >> 52; } \ No newline at end of file diff --git a/src/addition.h b/src/addition.h index e02a55a..20a8068 100644 --- a/src/addition.h +++ b/src/addition.h @@ -27,4 +27,6 @@ unsigned long long sign_double(unsigned long long a); unsigned long long precision_double(unsigned long long a); +unsigned long long exponent_double(unsigned long long number); + #endif // ADDITION_H \ No newline at end of file