comp.lang.ada
 help / color / mirror / Atom feed
From: DarthBob88 <darthbob88@gmail.com>
Subject: Re: Problem with Floating Points
Date: Thu, 13 Dec 2007 20:49:09 -0800 (PST)
Date: 2007-12-13T20:49:09-08:00	[thread overview]
Message-ID: <28673058-6075-454c-a0c1-1b529f897eb4@s12g2000prg.googlegroups.com> (raw)
In-Reply-To: a26c11ab-8209-48f1-9f64-6795de3071d3@t1g2000pra.googlegroups.com

On Dec 13, 8:19 pm, DarthBob88 <darthbo...@gmail.com> 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.



  reply	other threads:[~2007-12-14  4:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14  4:19 Problem with Floating Points DarthBob88
2007-12-14  4:49 ` DarthBob88 [this message]
2007-12-14  6:48 ` tmoran
2007-12-14  9:33 ` Keith Thompson
2007-12-14 14:15 ` Jeffrey Creem
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox