comp.lang.ada
 help / color / mirror / Atom feed
* Problem with Floating Points
@ 2007-12-14  4:19 DarthBob88
  2007-12-14  4:49 ` DarthBob88
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: DarthBob88 @ 2007-12-14  4:19 UTC (permalink / raw)


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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-12-14 14:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2007-12-14 14:15 ` Jeffrey Creem

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