Wallace Rather than being IntToBin it converts the n digit least significant bits to a string representation of 'binary' so IntToBin(1,4) would return '0001' IntToBin(3,4) returns '0011' IntToBin(15,5) = '01111'
Cant really see the use of it and the code isn't that flash Neven > Hi Chaps > > I found this on the web and it works but I don't understand how ? > > Can anyone explain it ? > > function IntToBin ( value:Integer; digits: integer ): string; > begin > result := StringOfChar ( '0', digits ) ; > while value > 0 do begin > if ( value and 1 ) = 1 then > result [ digits ] := '1'; > dec ( digits ) ; > value := value shr 1; > end; > end; > > Thanks Wallace > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > NZ Borland Developers Group - Delphi mailing list > Post: delphi@delphi.org.nz > Admin: http://delphi.org.nz/mailman/listinfo/delphi > Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: > unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe