B.1 Function Xemics_Dec2Storage(ByVal X As Double) As String
Dim iByte1 As Integer
Dim iByte2 As Integer
Dim iByte3 As Integer
Dim iByte4 As Integer
Dim iExp As Integer
Dim bNegative As Boolean
Dim fMantissa As Double
'Don't blow up with logs of zero
If X = 0 Then X = 0.00001
If X < 0 Then
bNegative = True
X = -X
End If
'find the correct exponent
iExp = Int((Log(X) / Log(2)) + 1) 'remember: log of any base is ln(x)/ln(base)
'MS byte is the exponent + 0x80
iByte1 = iExp + 128
'Divide input by this exponent to get mantissa
fMantissa = X / 2 ^ iExp
'Scale it up
fMantissa = fMantissa / 2 ^ -24
'Split the mantissa into 3 bytes
iByte2 = fMantissa \ 2 ^ 16
iByte3 = (fMantissa – (iByte2 * 2 ^ 16)) \ 2 ^ 8
iByte4 = fMantissa – (iByte2 * 2 ^ 16) – (iByte3 * 2 ^ 8)
If False = bNegative Then iByte2 = iByte2 And &H7F
Xemics_Dec2Storage = hexByte(iByte1) & hexByte(iByte2) & hexByte(iByte3) &
hexByte(iByte4)
End Function
你好请问这个有C语言的参考资料吗,谢谢!
KW X:
?C语言参考资料?亲;这得到图书馆或书店弄了。C语言并非TI制造;是一种通用编程工具语言。
Star Xu:
您用的是哪款芯片。
user4533238:
回复 Star Xu:
谢谢已经解决了!