开发者

convert a single into 8 bytes invb.net

I have a single that might have a decimal place but might not.

I have to put the digit before the decimal into the first 4 bytes and the digit after in the next 4 bytes.

So 1.1 would be 01-00-00-00-01-00-00-00

or 2.1 would be 02-00-00-00-01-00-00-00

or 1 would be 开发者_如何学JAVA01-00-00-00-00-00-00-00

The digit before the decimal point is stored like an integer in bytes the same with the digit after the point.

So 1.1 gets split into 1 and 1 and then stored as 2 DWORDS: 01000000 and 01000000


Like this:

Dim b(7) As Byte
b(0) = Convert.ToByte(Math.Floor(n))
b(4) = Convert.ToByte((n - Math.Floor(n)) * 10)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜