2011-12-06 63 views
-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

谢谢!

+0

你是一个链接,记录这8byte MSB格式? –

+0

当然,我仍然相信有人已经在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 –

+0

我问了这个链接,以便我们其他人可以赶上什么是MSB 。有一些很好的参考资料,我确定有人可以敲代码来完成转换。 –

回答

0

在使用它之后,转换双打并不像单打那么简单..(指数和螳螂不匹配)。

即使链接中的C代码在某些情况下也不能正常工作(这可能是因为它是为16位编译器设计的?我不知道,没有时间完全测试)..!

我已经遇到此ASM库(它说的它的自由),这解决了这个问题(必须导入它像C的DLL):

http://www.microdexterity.com/demos/mbfiee32.zip

好运在此之后的下一个,