MadSci Network: Computer Science
Query:

Re: In Delphi how do you convert binary numbers to dinary without using the Xor

Date: Sun Nov 12 09:25:03 2000
Posted By: Andrew Wood, Undergraduate, AstroPhysics & Cosmology
Area of science: Computer Science
ID: 973605726.Cs
Message:

Dear Grant

Never programming in Delphi before (but in plenty of other languages) I 
had to go hunting for a small function for you. I came across the 
following coding at the Delphi website. 

To convert from Binary (base 2) to Denary (base 10) in Delphi you can use 
the BinToInt function below.

function BinToInt(Value: String): LongInt; 
var 
  i,Size: Integer; 
begin 
  Result:=0; 
  Size:=Length(Value); 
  for i:=Size downto 0 do 
  begin 
    if Copy(Value,i,1)='1' then 
      Result:=Result+(1 shl i); 
  end; 
end; 

Hope this helps


Andrew S. Wood - MadSci Scientist

Resources:
----------
www.delphi3000.com  -  Searchword = "BinToInt"


Current Queue | Current Queue for Computer Science | Computer Science archives

Try the links in the MadSci Library for more information on Computer Science.



MadSci Home | Information | Search | Random Knowledge Generator | MadSci Archives | Mad Library | MAD Labs | MAD FAQs | Ask a ? | Join Us! | Help Support MadSci


MadSci Network, webadmin@www.madsci.org
© 1995-2000. All rights reserved.