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, LOTS_OF_MONEY 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-04-02 07:56:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!newsfeed.direct.ca!look.ca!newsfeed.icl.net!colt.net!newsfeeds.belnet.be!news.belnet.be!psinet-eu-nl!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: Mon, 2 Apr 2001 10:33:16 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9aa2jd$e4t$1@nh.pace.co.uk> References: <9e2x6.568987$JT5.15730002@news20.bellglobal.com> <9a2dnu$sff$1@nh.pace.co.uk> <3AC5C72F.8108A613@earthlink.net> <2GLx6.16115$aP5.1507862@newsread2.prod.itd.earthlink.net> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 986221997 14493 136.170.200.133 (2 Apr 2001 14:33:17 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 2 Apr 2001 14:33:17 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:6349 Date: 2001-04-02T14:33:17+00:00 List-Id: Here's a trick that might not have occurred to you: You want to set a "default base" and let the user type in a number like that without having to put in all the dingleberries around the digits. (Digits in this case is a misnomer. What is the word I want?) Prefix : constant String := "16#" ; Suffix : constant String := "#" ; .... Text_IO.Get_Line (Some_String, Last) ; .... Integer_Text_IO.Get ( From => Prefix & Some_String (1..Last) & Suffix, Item => Some_Integer, Last => Last) ; .... Naturally, you can do some setup with the prefix & suffix strings to make them selectable by the user at runtime. In the end, you probably want to read numbers in as strings anyway because you will want to create more forgiving editing than you customarily get immediately from Ada. (Quite often a response can be a number of things besides a number. Picture in your mind: "Enter the number or type 'Exit' to go back or 'Quit' to terminate...") Just another way of removing the epidermis from the household feline. 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/ "Phaedrus" wrote in message news:2GLx6.16115$aP5.1507862@newsread2.prod.itd.earthlink.net... > I've often thought that the "default base" in text_io should allow you to set > the default INPUT base, too, so that users of it could just specify that they > wanted the user to be able to plug in a number in a certain base without > using the base and pound signs. Unfortunately, it doesn't work that way. > > > To convert an inputted binary number to base ten, simply enter it as a > > binary number. If the program says "Get(N)", you can legally provide > > 38, 2#1001#, 16#DEADBEEF#, etc. > > True, and it works great, except that the base and pound signs are > sort of a pain. If you were going to enter, say, 30 or 40 binary numbers, > each consisting of 8 or more digits, orif you're writing a utility > to be used by less-than-advanced users, who might balk at writing the > base and the pound signs, or to convert binary data that is input as an > ASCII stream by an external device.... I can think of many situations where the > user might object to typing in the base and pound signs. (For instance, > what if the calculator in windows required you to put the base and pounds > around a number? Who'd use it?) > In that case, you're pretty much left with using a loop to get the number. And > once you've got it, it's kind of cool to be able to convert it without any > calculation. > I really love the look on people's faces when they ask to see the algorithm > for verification! "There isn't one" isn't an answer they're used to hearing. >