Hi,
we probably found a bug in Ada or we cannot realize, that this is indeed
a feature ;)
In Example A, we defined a simple modular ****ft to the left by means of
Item * 2**N. N is defined as an Integer. This example works well and
****ft_Left(2#1111#, 4) returns 0.
-- Example A
type Modular_Type is mod 2**4;
function ****ft_Left (Item : in Modular_Type;
N : in Integer) return Modular_Type is
begin
return Item * 2**N;
end ****ft_Left;
In Example B, we limit the parameter N to Positive, because we do not
want "negative" ****fts. The result of ****ft_Left(2#1111#, 4) is 224
(2#11100000#) !
-- Example B
type Modular_Type is mod 2**4;
function ****ft_Left (Item : in Modular_Type;
N : in Positive) return Modular_Type is
begin
return Item * 2**N;
end ****ft_Left;
Why does this happen? Positive is defined as all Integer values starting
at 1 through the highest value of Integer, so the result should also be
0. Especially, because the returning value is additionally limited by
mod 2**4.
Thanks,
Dennis Hoppe


|