From 2ee9c6a7df1c0c764ad3a607b5507113c1c07a3c Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Wed, 7 Feb 2024 11:34:51 +0100 Subject: [PATCH] addition double number output with sign, exponent and precision --- src/addition.c | 8 +++++++- src/addition.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/addition.c b/src/addition.c index 6b17097..5dcd167 100644 --- a/src/addition.c +++ b/src/addition.c @@ -77,7 +77,7 @@ unsigned int addition_precision_float(unsigned int p1, unsigned int p2) { return addition_uint(p1, p2); } -// writing number out of sign, exponent and precision +// writing floating number out of sign, exponent and precision unsigned int output_float(unsigned int sign, unsigned int exponent, unsigned int precision) { return (sign << 31) | (exponent << 23) | precision; @@ -129,4 +129,10 @@ unsigned long long precision_double(unsigned long long a) { unsigned long long exponent_double(unsigned long long number) { unsigned long long exponent = 0x7ff0000000000000; return (number & exponent) >> 52; +} + +// writing double number out of sign, exponent and precision + +unsigned long long output_double(unsigned long long sign, unsigned long long exponent, unsigned long long precision) { + return (sign << 63) | (exponent << 52) | precision; } \ No newline at end of file diff --git a/src/addition.h b/src/addition.h index 20a8068..0ed5aec 100644 --- a/src/addition.h +++ b/src/addition.h @@ -29,4 +29,6 @@ unsigned long long precision_double(unsigned long long a); unsigned long long exponent_double(unsigned long long number); +unsigned long long output_double(unsigned long long sign, unsigned long long exponent, unsigned long long precision); + #endif // ADDITION_H \ No newline at end of file