Bin2Int

Converts Binary to Integer

Function Bin2Int(binvalue)
 dim i, s, v, neg, ilen, value
 value = NULL
 if IsBin(binvalue) then
  value = 0
  s = binvalue
  ilen = Len(s)
  if (ilen=32) then
   v = Left(s, 1)
   neg = (cByte(v) = 1)
   if neg then
    s = BinNot(s)
   end if
  end if
  s = StrReverse(s)
  for i = 1 to ilen
   value = value + CByte(Mid(s, i, 1)) * Power(2, i-1)
  next
  if neg then
   value = -(value + 1)
  end if
 end if
 Bin2Int = value
End Function

binvalue

Views 286 Downloads 77

'Binary', 'Bin', 'Int', 'Integer', 'Convert', 'Change', 'Replace', 'substitute', 'NotMyWork'

ANmarAmdeen
323
Math Classic ASP
Revisions

v2.0