On Fri, 15 Oct 2004 15:12:43 +0200, Nils O. Selåsdal <(E-Mail Removed)> wrote:

> Magix wrote:

>> Hi,

>> Can I do this?

>> long mantissa; long x1; long x2;

>> word a1; word a2;

>> int exp;

>> double result;

>> a1= 0x1234

>> a2 = 0x5678

>> x1 = (a1 << 16)

>> x2 =(a2 & 0x0000FFFF)

> the last one here is probably not needed...

> use unsigned types btw, so tou don't get to many

> surprises.

>
Why the last one x2=(a2 & 0x0000FFFF) not needed?

if I have a1=0x1234, a2=0x5678, mantissa must be 0x56781234. To construct

that, I only need to left shift a2 16? and then x1|x2 ?

>> mantissa= x1 | x2

>> so that I will have 0x56781234

> Yes, assuming that long and "word" on your

> system are able to hold enough bits for this,

> and that the above is more or less pseudocode.

>
Actually,i want to put mantissa and exp into ldexp (math.h) function.

and the result should be xxx.xxxxxx (%5lf). So probably define

unsigned double result?

>> result = ldexp(mantissa, exp);

> Uhmm, that line is totally out of context, what's

> the meaning of this-
--

Using Opera's revolutionary e-mail client:

http://www.opera.com/m2/