comp.lang.ada
 help / color / mirror / Atom feed
From: "gilrain" <john.thile@murraystate.edu>
Subject: "In reverse" in for loop acting weird.
Date: Sun, 29 Sep 2002 12:28:40 -0500
Date: 2002-09-29T12:28:40-05:00	[thread overview]
Message-ID: <PFGl9.81453$5M3.3538442@e3500-atl2.usenetserver.com> (raw)

Hi all,

Okay, my program is working perfectly except for this one minor detail. The
result (stored in a string) prints exactly backward. What's baffling me is
that it's still backward even when I reverse the process for building the
string. Here's the offending code segment:

for j in reverse -15..15 loop
   case integer(abs(coefficients(j))) is
      when 0 => result(j+16) := '0';
      when 1 => result(j+16) := '1';
      when 2 => result(j+16) := '2';
      when 3 => result(j+16) := '3';
      when 4 => result(j+16) := '4';
      when 5 => result(j+16) := '5';
      when 6 => result(j+16) := '6';
      when 7 => result(j+16) := '7';
      when 8 => result(j+16) := '8';
      when 9 => result(j+16) := '9';
      when 10 => result(j+16) := 'A';
      when 11 => result(j+16) := 'B';
      when 12 => result(j+16) := 'C';
      when 13 => result(j+16) := 'D';
      when 14 => result(j+16) := 'E';
      when 15 => result(j+16) := 'F';
      when 16 => result(j+16) := 'G';
      when others => result(j+16) := '!';
   end case;
end loop; result(16) := '.';

Coefficients is an array of long floats which at this point in the program
only contains whole numbers. I want coefficients(15) to be the first
character in the string, and so on to -15. The above code prints it
backwards, but the thing which gets me is that taking out "reverse" doesn't
change the program output one bit!

Will someone clue me in?

Thanks,

John Thile






             reply	other threads:[~2002-09-29 17:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-29 17:28 gilrain [this message]
2002-09-29 17:59 ` "In reverse" in for loop acting weird Martin Dowie
2002-09-29 21:15   ` Martin Dowie
2002-09-29 18:31 ` tmoran
2002-09-29 19:17   ` gilrain
2002-09-29 18:49 ` Jeffrey Carter
2002-09-29 19:19   ` gilrain
replies disabled

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