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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b80661021d9cbcb1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!s12g2000prg.googlegroups.com!not-for-mail From: DarthBob88 Newsgroups: comp.lang.ada Subject: Re: Problem with Floating Points Date: Thu, 13 Dec 2007 20:49:09 -0800 (PST) Organization: http://groups.google.com Message-ID: <28673058-6075-454c-a0c1-1b529f897eb4@s12g2000prg.googlegroups.com> References: NNTP-Posting-Host: 66.228.25.2 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1197607749 1690 127.0.0.1 (14 Dec 2007 04:49:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 14 Dec 2007 04:49:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s12g2000prg.googlegroups.com; posting-host=66.228.25.2; posting-account=Wx82cgoAAACNa4nrJhRV8xCn3wMN2wR_ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:18939 Date: 2007-12-13T20:49:09-08:00 List-Id: On Dec 13, 8:19 pm, DarthBob88 wrote: > I'm trying to use a Percentage type to show how often a given > condition occurred; like percent := matches/attempts. The only problem > is, it keeps outputting 0% for the result percentage. I have been > unable to get it to change its output, even to another nonsense answer > like that. Here follows my program, without the irrelevant portions. > > with Ada.Text_IO, Ada.Integer_Text_IO; > use Ada.Text_IO, Ada.Integer_Text_IO; > > procedure test is > type Percentage is Delta 0.01 range 0.00 .. 100.00; > --Runs from 0 to 100%, and goes to two decimal places. > > Successes : Integer := 0; > Attempts : Integer := 0; > Output : Percentage; > begin > > loop > Attempts := Attempts + 1; > --when we get a success > Successes := Successes + 1; > > exit when iterator = 1000; > end loop; > Output := 100.00 * (Successes / Iterator); > Put_Line("Attempts: " & Integer'Image(Attempts)); > New_Line; > Put_Line("Successes: " & Integer'Image(Successes)); > New_Line; > Put_Line("Percentage of Successes: " & > Percentage'Image(Output)); > end Test; > > I've been able to get real outputs for Attempts and Successes, but > nothing at all for Output. I've been looking through every other > source available, but nothing had an answer for me. Never mind, it works the way it should now. Apparently, I wasn't going out to enough places for Successes/Iterator to actually show up as a number.