DecToBin
Converting numbers to binary [email protected] (Alan Davis)
AI
Yapay Zeka Özeti: 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.
Kaynak Kod
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;
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı