Agilent Technologies 86082A User Manual page 246

Wavelength domain component analyzer
Table of Contents

Advertisement

'-- This function will get the entire IEE-754 compliant binary number and convert it to
'-- a value that is usable to VB.
'
'-- Defaults
Dim Bias As Integer: Bias = 127
Dim ExpSize As Integer: ExpSize = 8
'-- Calculated variables
Dim BinaryStr As String
Dim SignBit As Integer: SignBit = 1
Dim Exp As Double
Dim Mantissa As Double
Dim MantValLen As Integer
Dim MantStart As Integer
Dim LSOne As Integer
Dim Status As Long
Const EXP_START = 2
On Error GoTo ErrorHandler
'-- Data defaults to REAL32. If REAL64, make adjustments accordingly
If eDataSize = eREAL64 Then
Bias = 1023
ExpSize = 11
End If
'-- The binary string contains ASCII character codes. Convert this to true binary
BinaryStr = prvtBinASCToBinStr(BinASCVal)
'-- Check sign bit
If Left(BinaryStr, 1) = "1" Then SignBit = -1
'-- Translate exponent to decimal number
Exp = prvtBinStrToDec(Mid(BinaryStr, EXP_START, ExpSize), Status, ErrMsg)
If Status <> 0 Then Call Err.Raise(Status, "prvtBinStrToDec", ErrMsg)
'-- If Exp is not 0, the value is normalized
If Exp <> 0 Then
'-- Further Translate exponent: 2^(ExpValue - Bias)
Exp = 2 ^ (Exp - Bias)
End If
'-- Find the least significant "1" in the string
LSOne = InStrRev(BinaryStr, "1")
MantStart = ExpSize + EXP_START
'-- If a 1 was found, calculate the Mantissa, otherwise check for different values
'-- according to IEEE-754 standards
If (LSOne <> 0) And (LSOne > MantStart) Then
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
'1 or -1
Remote Operation
Example Programs
5-71

Advertisement

Table of Contents
loading

Table of Contents