comp.lang.ada
 help / color / mirror / Atom feed
* AW: Static vs dynamic evaluation anomaly?
  2007-02-06 20:01 Adam Beneschan
@ 2007-02-07  6:24 ` Grein, Christoph (Fa. ESG)
  2007-02-07  6:59   ` Stefan Lucks
  0 siblings, 1 reply; 3+ messages in thread
From: Grein, Christoph (Fa. ESG) @ 2007-02-07  6:24 UTC (permalink / raw)
  To: Adam Beneschan, comp.lang.ada

No, this program is absolute correct. Modular types do not overflow,
they use modular arithmetic.

with Ada.Text_IO;
use  Ada.Text_IO;
procedure test271 is
  type Six_Bits is mod 2**6;
  X: constant Six_Bits := 31;
  Z: constant Integer  := 31;
begin
  for J in 0..5 loop
    Put_Line (Integer 'Image         (J) &
              Six_Bits'Image  (X * 2**J) &
              Integer 'Image ((X * 2**J) mod Six_Bit'Modulus));
  end loop;
end test271;



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

* Re: AW: Static vs dynamic evaluation anomaly?
  2007-02-07  6:24 ` AW: " Grein, Christoph (Fa. ESG)
@ 2007-02-07  6:59   ` Stefan Lucks
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Lucks @ 2007-02-07  6:59 UTC (permalink / raw)


There seems to be something wrong with the Put_Line statement:

On Wed, 7 Feb 2007, Grein, Christoph (Fa. ESG) wrote:

> with Ada.Text_IO;
> use  Ada.Text_IO;
> procedure test271 is
>   type Six_Bits is mod 2**6;
>   X: constant Six_Bits := 31;
>   Z: constant Integer  := 31;
> begin
>   for J in 0..5 loop
>     Put_Line (Integer 'Image         (J) &
>               Six_Bits'Image  (X * 2**J) &
>               Integer 'Image ((X * 2**J) mod Six_Bit'Modulus));
    Put_Line (Integer 'Image         (J) &
              Six_Bits'Image  (X * 2**J) &
              Integer 'Image ((Integer(X) * 2**Integer(J))
                                mod Six_Bits'Modulus)
             );
>   end loop;
> end test271;
>

-- 
Stefan Lucks      Th. Informatik, Univ. Mannheim, 68131 Mannheim, Germany
            e-mail: lucks@th.informatik.uni-mannheim.de
            home: http://th.informatik.uni-mannheim.de/people/lucks/
------  I  love  the  taste  of  Cryptanalysis  in  the  morning!  ------




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

* AW: Static vs dynamic evaluation anomaly?
       [not found] <AEBEAAA73D5180469E2B3F071A96AC220110A637@sma2901.cr.eurocopter.corp>
@ 2007-02-07  7:22 ` Grein, Christoph (Fa. ESG)
  0 siblings, 0 replies; 3+ messages in thread
From: Grein, Christoph (Fa. ESG) @ 2007-02-07  7:22 UTC (permalink / raw)
  To: Grein, Christoph (Fa. ESG), comp.lang.ada

Silly me, I meant

with Ada.Text_IO;
use  Ada.Text_IO;
procedure test271 is
  type Six_Bits is mod 2**6;
  X: constant Six_Bits := 31;
  Z: constant Integer  := 31;
begin
  for J in 0..5 loop
    Put_Line (Integer 'Image         (J) &
              Six_Bits'Image  (X * 2**J) &
              Integer 'Image ((Z * 2**J) mod Six_Bits'Modulus));
  end loop;
end test271;
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada-france.org
http://www.ada-france.org/mailman/listinfo/comp.lang.ada




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

end of thread, other threads:[~2007-02-07  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AEBEAAA73D5180469E2B3F071A96AC220110A637@sma2901.cr.eurocopter.corp>
2007-02-07  7:22 ` AW: Static vs dynamic evaluation anomaly? Grein, Christoph (Fa. ESG)
2007-02-06 20:01 Adam Beneschan
2007-02-07  6:24 ` AW: " Grein, Christoph (Fa. ESG)
2007-02-07  6:59   ` Stefan Lucks

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