Re: decimal to binary

"Axel Canicio" <[email protected]> Fri, 15 Aug 2003 00:37:08 +0200
Newsgroups gmane.comp.lang.delphi.programming
Message-ID <002301c362b4$c2bf5420$f8099284@P42400>
Hello, hum... gws32750 ?

Here a little function that does the conversion :

Function DecBin(Value : Longint):String;
   Var TmpInt : Longint;
       Bin : String;
   Begin
      Bin :='';
      Repeat
         TmpInt := Value mod 2;
         Value := Value Div 2;
         Bin := IntToStr(TmpInt)+Bin;
      Until Value < 1;
      Result := Bin;
   End;


It works for any integer up to 32bits

Then up to you to use the individual char values in the resulting string to
control your checkboxes.
You know, use string_value[<position>] from 8 to 1 for example.

Best regards
Axel


----- Original Message -----
From: "gws32750" <[email protected]>
To: <[email protected]>
Sent: Friday, August 15, 2003 12:07 AM
Subject: [Delphi] decimal to binary


> Hi I am beginner in programming would like to ask the following. I
> am looking for a fast way to convert a decimal number (0-256) into
> binary and then set the value of eight differnt check boxes based on
> the value of the binary number.
>
> I have done it but my code is very long and cumbersome and am
> looking for shorter ways  so that I can learn
>
> Thank you.
>
>
>
> CodeCoffer - new Delphi code protection Tool!
> http://www.delphicollection.com/public/CodeCoffer.htm
> ---------------------------------------------------------------
> Unsubscribe:[email protected]
> List owner:[email protected]
> ---------------------------------------------------------------
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

>
>


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/i7folB/TM
---------------------------------------------------------------------~->

CodeCoffer - new Delphi code protection Tool!
http://www.delphicollection.com/public/CodeCoffer.htm
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
--------------------------------------------------------------- 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/