Hi Magix,
Of course you can, but to no avail.
I already asked you in other threads and ask you one last time:
Please give us a piece of code that runs.
Either a minimal example or whatever.
Your code below does not work and cannot work.
Tell us what you want to achieve.
long mantissa; long x1; long x2;
word a1; word a2;
word is not a C type.
If you want to work with bitwise operations, it is
a Good Idea to use unsigned integer types.
Use
unsigned long mantissa, x1, x2;
unsigned int a1, a2;
int exp;
double result;
a1= 0x1234
a2 = 0x5678
This lacks semicolons.
x1 = (a1 << 16)
x2 =(a2 & 0x0000FFFF)
mantissa= x1 | x2
so that I will have 0x56781234
Not at all.
x1 is a1 shifted left by 16, i.e. 0x12340000, so
x1|x2 is 0x12345678.
result = ldexp(mantissa, exp);
From the ldexp manpage on my system:
"
ldexp - multiply floating-point number by integral power of 2
SYNOPSIS
#include <math.h>
double ldexp(double x, int exp);
DESCRIPTION
The ldexp() function returns the result of multiplying the
floating-point number x by 2 raised to the power exp.
CONFORMING TO
SVID 3, POSIX, BSD 4.3, ISO 9899
"
I guess that you want to do something along the lines of
setting the mantissa bits of a double variable with bitwise
operations and then multiply it by pow(2,exp).
This cannot be done portably.
Rather get yourself a number in the range 0<=x<1 and then
scale it with ldexp.
If my guess is wrong: Call mantissa differently to avoid
the impression that it should be a double.
--Michael