Bin2Int

Converts Binary to Integer


Public

Tested

My Own Work
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 4088 Downloads 1102

Classic ASP Math
ANmarAmdeen
655
Revisions

v2.0