- VB.NET質問スレ(Part42) [転載禁止]©2ch.net
567 :デフォルトの名無しさん[sage]:2015/09/13(日) 21:12:55.28 ID:zY9i8RMC - BitConverter.ToSingle に関する質問です。
Private Function fn4Bytes2Singel(ByVal Offset As Integer) As Single 'parse 4 of bytes into an Single value, Dim bytaryData(3) As Byte 'byte array structure Dim SglData As Single Dim Ix As Integer 'index counter For Ix = 0 To 3 bytaryData(Ix) = aryBuffer(Offset + Ix) Next Ix SglData = BitConverter.ToSingle((bytaryData), 0) Return SglData End Function ファイルのデータを aryBuffer() as byte に読み込んで、そこに正しく記録されている Single 形式の 4 バイトから値を取得すると言う単純な Function です。 しかし、03 84 8A 4B と 04 84 8A 4B と 05 84 8A 4B が同じ値 18155530 を返してきます。 IEEE に準拠した形式であれば 18155526 18155528 18155530 になるはずで、WEB 上の コンバーターでは、正しく変換されます。 BitConverter.ToSingle の仕様とも思えないのですが、回避する手段をご存じの方が おられましたら、ご教授頂けますよう、お願い致します。
|