comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Problem with Floating Points
Date: Fri, 14 Dec 2007 01:33:24 -0800
Date: 2007-12-14T01:33:24-08:00	[thread overview]
Message-ID: <lnabod1uzf.fsf@nuthaus.mib.org> (raw)
In-Reply-To: a26c11ab-8209-48f1-9f64-6795de3071d3@t1g2000pra.googlegroups.com

DarthBob88 <darthbob88@gmail.com> 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  <http://www.ghoti.net/~kst>
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"



  parent reply	other threads:[~2007-12-14  9:33 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
2007-12-14  6:48 ` tmoran
2007-12-14  9:33 ` Keith Thompson [this message]
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