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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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:52:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!news-out.visi.com!hermes.visi.com!pulsar.dimensional.com!dimensional.com!coop.net!newsfeed1.global.lmco.com!svlnews.lmms.lmco.com!not-for-mail From: "Smark" Newsgroups: comp.lang.ada Subject: Re: Binary value Date: Fri, 30 Mar 2001 14:45:45 -0600 Organization: Lockheed Martin Corporation Message-ID: <9a2r9o$kf42@cui1.lmms.lmco.com> References: <9e2x6.568987$JT5.15730002@news20.bellglobal.com> <9a2dnu$sff$1@nh.pace.co.uk> <9a2qhh$jee4@cui1.lmms.lmco.com> NNTP-Posting-Host: 138.209.253.101 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Xref: supernews.google.com comp.lang.ada:6272 Date: 2001-03-30T14:45:45-06:00 List-Id: "Smark" wrote in message news:9a2qhh$jee4@cui1.lmms.lmco.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!} > > Well, Chris, you would probably change your mind if you tried it! > As in your example, say you start with 123. > > First pass through loop: > rem := 123 mod 2 ( = 1) > num := 123 - 1 ( = 122) > add "1" to front of string -- so the string now looks like "1" > > Second pass: > rem := 122 mod 2 ( = 0) > num := 122 - 0 ( = 122) > add "0" to front of string -- so the string now looks like "01" > > Third pass: > rem := 122 mod 2 ( = 0) > num := 122 - 0 ( = 122) > add "0" to front of string -- so the string now looks like "001" > > Beginning to see a problem here? > > I think the algorithm you were trying to think of goes something like: > Okay, I take it back. The algorithm I provided does work, but it is not the one you were thinking of. That would be more like: while num /= 0 loop rem := num mod 2; -- get remainder num := Floor(num/2); add rem'image to front* of string; end loop; Mark Arlington, Texas