Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Feature or Bug?...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 13 Topic 5736 of 5857
Post > Topic >>

Feature or Bug? 2#1111# ****fted by 4 is 224

by Dennis Hoppe <dennis.hoppe@[EMAIL PROTECTED] > Jun 2, 2008 at 05:17 PM

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
 




 13 Posts in Topic:
Feature or Bug? 2#1111# shifted by 4 is 224
Dennis Hoppe <dennis.h  2008-06-02 17:17:19 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Tero Koskinen <tero.ko  2008-06-02 19:11:45 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Ludovic Brenta <ludovi  2008-06-03 01:10:25 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Adam Beneschan <adam@[  2008-06-03 10:56:13 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
"Jeffrey R. Carter&q  2008-06-03 19:39:18 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Ludovic Brenta <ludovi  2008-06-02 19:59:33 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Dennis Hoppe <dennis.h  2008-06-02 20:52:26 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
"Jeffrey R. Carter&q  2008-06-03 00:51:29 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Gautier <gautier@[EMAI  2008-06-03 06:26:02 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
"Jeffrey R. Carter&q  2008-06-03 19:36:52 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Samuel Tardieu <sam@[E  2008-06-03 14:59:25 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Gautier <gautier@[EMAI  2008-06-03 00:32:33 
Re: Feature or Bug? 2#1111# shifted by 4 is 224
Tero Koskinen <tero.ko  2008-06-04 06:36:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 4:34:14 CDT 2008.