有会delphi7和C#的大侠帮帮忙!!!
大侠,帮小弟把下面的代码翻译成c#的吧,有些地方实在是看不明白啊
lsfloat:=GetReal(Byte(S[counter+14]),Byte(S[counter+15]),Byte(S[counter+16]),Byte(S[counter+17]));
Form1.Tim0.Text:=format('%0.4f',[lsfloat]);
function GetReal(B1,B2,B3,B4:Byte):Extended;
var
int,exp :integer;
expf,f1:Extended ;
fa:integer;
begin
if(B1 AND $80 =$80 )then begin
fa:=-1;
B1:=B1 AND $00007F;
end
else begin
fa:=1;
end;
B1:=B1+$80;
int:=B1*65536+B4*256+B3;
exp:=B2-$80;
exp:=23-exp;
expf:=exp;
expf:=power(2,expf);
f1:=int;
expf:=f1 / expf;
GetReal:=expf*fa;
end;
------解决方案--------------------
既然不好转,那直接做成标准的API的dll,到处来,用平台调用!
C# code
[DllImport(xxx.dll, EntryPoint = "GetReal")]
public static extern void GetReal(byte B1,byte B2,byte B3,byte B4);