* bugfix for int64 to float conversion

This commit is contained in:
carl 2002-10-13 15:47:39 +00:00
parent 87d0fb3cda
commit c0a2149c38

View File

@ -4597,51 +4597,47 @@ End;
| to the double-precision floating-point format. The conversion is performed | to the double-precision floating-point format. The conversion is performed
| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
*----------------------------------------------------------------------------*} *----------------------------------------------------------------------------*}
function int64_to_float64( a: int64 ): float64; function int64_to_float64( a: int64 ): float64;
var var
zSign : flag; zSign : flag;
float_result : float64; float_result : float64;
intval : int64rec; intval : int64rec;
AbsA : bits64;
shiftcount : int8;
zSig0, zSig1 : bits32;
Begin Begin
if ( a = 0 ) then if ( a = 0 ) then
begin Begin
int64_to_float64.low := 0; packFloat64( 0, 0, 0, 0, float_result );
int64_to_float64.high := 0; exit;
exit;
end; end;
if ( a = sbits64 ( 1 shl 64 ) ) then zSign := flag( a < 0 );
begin if ZSign<>0 then
packFloat64(1, $43E, 0, 0, float_result); AbsA := -a
int64_to_float64 := float_result;
exit;
end;
if a < 0 then
zSign := flag(TRUE)
else else
zSign := flag(FALSE); AbsA := a;
if zSign<>0 then shiftCount := countLeadingZeros64( absA ) - 11;
a := -a; if ( 0 <= shiftCount ) then
if zSign <> 0 then Begin
begin absA := absA shl shiftcount;
a:=-a; zSig0:=int64rec(absA).high;
intval.low := int64rec(a).low; zSig1:=int64rec(absA).low;
intval.high := int64rec(a).high; End
normalizeRoundAndPackFloat64( zSign, $43C, intval.low, intval.high , float_result )
end
else else
begin Begin
intval.low := int64rec(a).low; shift64Right( absA, 0, - shiftCount, zSig0, zSig1 );
intval.high := int64rec(a).high; End;
normalizeRoundAndPackFloat64( zSign, $43C, intval.low, intval.high , float_result ); packFloat64( zSign, $432 - shiftCount, zSig0, zSig1, float_result );
end;
int64_to_float64:= float_result; int64_to_float64:= float_result;
End; End;
end. end.
{ {
$Log$ $Log$
Revision 1.3 2002-10-12 20:24:22 carl Revision 1.4 2002-10-13 15:47:39 carl
* bugfix for int64 to float conversion
Revision 1.3 2002/10/12 20:24:22 carl
+ int64_tof_loat conversion routines + int64_tof_loat conversion routines
Revision 1.2 2002/10/08 20:07:08 carl Revision 1.2 2002/10/08 20:07:08 carl