Below are some pascal declarations and code that will transform a 6 byte TP real to an 8 byte IEEE real.

Translating this into C should be pretty simple...

Cheers,

Raymond.

treal6 = record

case boolean of

true : (value : real);

false : (exp : byte ; mant2 : byte5);

end;

real8 = record

case boolean of

true : (byteval : byte8);

false : (mant1 : integer; mant2 : byte5; exp : byte);

end;

turbo86 = record

case boolean of

true : (tval : byte6);

false :(rval : real);

end;

turbo87 = record

case boolean of

true : (tval : byte8);

false: (rval : real);

end;

procedure conv86_87(real86 : turbo86;var real87 : turbo87);

{ convert a turbo86 real number to a turbo87 real number }

var

i,j,newexp : integer;

sign : byte;

begin

{$IFOPT R+} {$DEFINE Rchk2} {$R-} {$ENDIF}

if real86.tval[1] = 0 then newexp := 0

else

newexp := (real86.tval[1] + 894) shl 4;

sign := real86.tval[6] and 128; { extract sign bit }

real87.tval[8] := sign or (hi(newexp) and 127);

real87.tval[7] := (lo(newexp) and 240) or ((real86.tval[6] shr 3) and 15);

for i := 5 downto 2 do

real87.tval[i+1] := (real86.tval[i+1] shl 5) or (real86.tval[i] shr 3);

real87.tval[2] := (real86.tval[2] shl 5) and $ff;

real87.tval[1] := 0;

{$IFDEF Rchk} {$UNDEF Rchk2} {$R+} {$ENDIF}

end;

{-------------------------

PROCEDURE real_to_double(the_real : system.real; VAR the_double : byte8);

VAR

turbo86_buffer : turbo86 ABSOLUTE the_real;

turbo87_buffer : turbo87 ABSOLUTE the_double;

BEGIN

conv86_87(turbo86_buffer, turbo87_buffer);

END;