From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a96b706fab1e8c2c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-30 12:22:18 PST Path: supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!news-x.support.nl!isdnet!psinet-france!psiuk-f4!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Binary value Date: Fri, 30 Mar 2001 15:03:20 -0500 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9a2oqa$2p9$1@nh.pace.co.uk> References: <9e2x6.568987$JT5.15730002@news20.bellglobal.com> <9a2dnu$sff$1@nh.pace.co.uk> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 985982602 2857 136.170.200.133 (30 Mar 2001 20:03:22 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 30 Mar 2001 20:03:22 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: supernews.google.com comp.lang.ada:6269 Date: 2001-03-30T20:03:22+00:00 List-Id: It is *MUCH* easier simply to look at what is available to you in Text_IO. >From ARM A.10.8: ============================================= procedure Put(To : out String; Item : in Num; Base : in Number_Base := Default_Base); Outputs the value of the parameter Item to the given string, following the same rule as for output to a file, using the length of the given string as the value for Width. ================================================ This will put an integer value in any base you like (almost!) into a string. Similar stuff exists for other numeric types. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/ "chris.danx" wrote in message news:K84x6.4066$MZ2.743519@news2-win.server.ntlworld.com... > > I see... that answers half of my question. This presumes I wanna convert > > from binary to Integer. But is it possible to "convert" a Integer value to > > binary. > > Suppose you have the value 123 in binary. To convert to binary you need to > follow this algorithm. > > while num /= 0 loop > rem := num mod 2; -- get remainder > num := num - rem; > add rem'image to front* of string; > end loop; > > {I think this is the correct algorithm!} > > You could do it recursively too. > > > Hope this helps, > Chris Campbell > > *if you add rem'image onto the end you'll have to reverse the string after > you finish so it'd be better to add it to the front. I'm assuming you'll > use an unbounded string in the loop and will convert it to a string outside > if you wish. > >