⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3-4.pas

📁 3字节4字节浮点数转换程序
💻 PAS
字号:
function Float3ByteTo4Byte( ch3: pointer; fptr: pointer ):integer;
var
   index,index2: byte;
   a: integer;
   Ptr4: pointer;
begin
     Ptr4 := fptr;
     if	(( byte(ch3^) and $40 ) = $40) then begin
    	index := byte(byte(ch3^) and $3f);
        if ((byte(ch3^) and $01) = $00) then
           index2 := byte(pointer(longint(ch3)+1)^) and $7f
        else begin
             index2 := byte(pointer( longint(ch3) + 1 )^);
    	     index := index - 1;
    	end;

    	if ((byte(ch3^) and $80) = $80) then
          index := index or $80
        else
           index := index and $7f;

        byte(Ptr4^) := 0;
        byte(pointer(longint(Ptr4) + 1 )^) := byte(pointer(longint(ch3) +2 )^);
        byte(pointer(longint(Ptr4) + 2 )^) := byte(index2);
        byte(pointer(longint(Ptr4) + 3 )^) := byte(index);

        if ( byte(ch3^) = $41 ) or ( byte(ch3^) = $00 ) then begin
           byte(Ptr4^) := 0;
           byte(pointer(longint(Ptr4) + 1 )^) := 0;
           byte(pointer(longint(Ptr4) + 2 )^) := 0;
           byte(pointer(longint(Ptr4) + 3 )^) := 0;
        end;
     end
     else
         index := (byte(ch3^) and $3f) + 126;

     if ((index and $01) = $01) then
        index2 := byte(pointer(longint(ch3)+1)^) or $80
     else
         index2 := byte(pointer(longint(ch3)+1)^) and $7f;

     index := index shr 1;

     if ((byte(ch3^) and $80) = $80) then
        index := index or $80
     else
         index := index and $7f;

     byte(Ptr4^) := 0;
     byte(pointer(longint(Ptr4) + 1 )^) := byte(pointer(longint(ch3) +2 )^);
     byte(pointer(longint(Ptr4) + 2 )^) := index2;
     byte(pointer(longint(Ptr4) + 3 )^) := index;

     if ( byte(ch3^) = $41 ) or ( byte(ch3^) = $00 ) then begin
        byte(Ptr4^) := 0;
        byte(pointer(longint(Ptr4) + 1 )^) := 0;
        byte(pointer(longint(Ptr4) + 2 )^) := 0;
        byte(pointer(longint(Ptr4) + 3 )^) := 0;
     end;

     a :=36;
     result := a;
end;

function Float4ByteTO3Byte( ch3: pointer; fPtr: pointer):integer;
var
   index: byte;
   ch4: pointer;
   a: integer;
begin
     ch4 := fptr;
     if ( byte(pointer(longint(ch4)+2)^) and $80) = $80 then
        index := ( byte(pointer(longint(ch4)+3)^) shl 1 )+1
     else
         index := byte( pointer(longint(ch4)+3)^) shl 1;

     if shortint(index - $7f) < 0 then begin
        index := index-127;
        index := (abs(index) or $40)+1;
     end
     else begin
          index := index-127;
          index := ( abs(index) and $bf )+1;
     end;

     if (byte(pointer(longint(ch4)+3)^) and $80) = $80 then
        index := index or $80
     else
         index := index and $7f;

     byte(ch3^) := index;
     byte(pointer( longint(ch3) + 1 )^) :=  byte(pointer( longint(ch4) +2 )^) or $80;
     byte(pointer(longint(ch3) + 2 )^) := byte(pointer(longint(ch4) + 1 )^);

     a := 37;
     result := a;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -