-1
有人有代码从旧MSB转换为ieee(delphi real)?delphi将微软二进制转换为ieee(8bits)
在谷歌,我只成立了4位转换,而不是8位:
function MBF2IEEE(MBFVal: Single): Single;
var
Output: array[1..4] of byte;
Value: Single absolute Output;
// Sign: byte;
LSB: Byte;
begin
try
Output[4] := TInput(MBFVal)[4];
{ if value is non-zero, do some bit shuffling }
if Output[4] > 2 then begin
Output[3] := TInput(MBFVal)[3];
Output[2] := TInput(MBFVal)[2];
Output[1] := TInput(MBFVal)[1];
Output[4] := Output[4] - $02;
LSB := Output[4] and $01;
Output[4] := (Output[4] shr 1) or (Output[3] and $80);
if LSB = 0 then
Output[3] := Output[3] and $7f
else
Output[3] := Output[3] or $80;
{ else return 0 }
end else begin
Output[1] := 0;
Output[2] := 0;
Output[3] := 0;
Output[4] := 0;
end;
Result := Value;
except
Output[1] := 0;
Output[2] := 0;
Output[3] := 0;
Output[4] := 0;
end;
end;
(从这个页面 http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20245266.html)
谢谢!
你是一个链接,记录这8byte MSB格式? –
当然,我仍然相信有人已经在Delphi中完成了这项工作.. http://support.microsoft.com/kb/35826 http://www.elchabon.com/2010/07/mbfmicrosoft-binary-格式到ieee转换/ http://stackoverflow.com/questions/3766023/convert-mbf-double-to-ieee –
我问了这个链接,以便我们其他人可以赶上什么是MSB 。有一些很好的参考资料,我确定有人可以敲代码来完成转换。 –