Browse Source

addition double number output with sign, exponent and precision

master
Dennis Sperzel 11 months ago
parent
commit
2ee9c6a7df
  1. 8
      src/addition.c
  2. 2
      src/addition.h

8
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;
}

2
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
Loading…
Cancel
Save