Advertisement
ASP_Volume3 Math/ Dates #44437

DecToBin

Converting numbers to binary [email protected] (Alan Davis)

AI

AI சுருக்கம்: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

மூலக் குறியீடு
original-source
Public Function DecToBin(ByVal DecNumber As Currency) As String
  
On Error GoTo DecToBin_Finally
Dim BinNumber As String
Dim i%
  
  For i = 64 To 0 Step -1
    If Int(DecNumber / (2 ^ i)) = 1 Then
      BinNumber = BinNumber & "1"
      DecNumber = DecNumber - (2 ^ i)
    Else
      If BinNumber <> "" Then
        BinNumber = BinNumber & "0"
      End If
    End If
  Next
  
  DecToBin = BinNumber
  
DecToBin_Finally:
  
  If Err <> 0 Or BinNumber = "" Then DecToBin = "-E-"
  Exit Function
  
End Function

type
 TSplitArray = array of String;
function Split(const Source, Delimiter: String): TSplitArray;
var
 iCount: Integer;
 iPos: Integer;
 iLength: Integer;
 sTemp: String;
 aSplit: TSplitArray;
begin
 sTemp := Source;
 iCount := 0;
 iLength := Length(Delimiter) - 1;
 repeat
 iPos := Pos(Delimiter, sTemp);
 if iPos = 0 then
 break
 else begin
 Inc(iCount);
 SetLength(aSplit, iCount);
 aSplit[iCount - 1] := Copy(sTemp, 1, iPos - 1);
 Delete(sTemp, 1, iPos + iLength);
 end;
 until False;
 if Length(sTemp) > 0 then begin
 Inc(iCount);
 SetLength(aSplit, iCount);
 aSplit[iCount - 1] := sTemp;
 end;
 
 Result := aSplit;
end;
அசல் கருத்துகள் (3)
வேபேக் மெஷினிலிருந்து (Wayback Machine) மீட்டெடுக்கப்பட்டது