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-Thread: 103376,b80661021d9cbcb1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!post02.iad01!roadrunner.com!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Problem with Floating Points References: From: Keith Thompson Organization: None to speak of Date: Fri, 14 Dec 2007 01:33:24 -0800 Message-ID: User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:vRF5JZHFAAdYK9SRbSOU+SHGE5U= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 75.80.183.54 X-Complaints-To: abuse@rr.com Xref: g2news1.google.com comp.lang.ada:18944 Date: 2007-12-14T01:33:24-08:00 List-Id: DarthBob88 writes: > 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; It would help if you posted your actual program. The above doesn't compile (iterator is undefined). > 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. What do you mean by "nothing at all"? Does it print 0.0? Does it really not print anything? -- Keith Thompson (The_Other_Keith) kst-u@mib.org Looking for software development work in the San Diego area. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"