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 > Re: Problem usi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 5808 of 5966
Post > Topic >>

Re: Problem using Ada.Text_IO.Modular_IO

by micronian2@[EMAIL PROTECTED] Jul 14, 2008 at 09:34 AM

Hi,

In the context of using types such as Unsigned_N from Interfaces, what
if you needed the bit ****fting operations? From looking at the RM,
they are only available for modular types defined in Interfaces:

Ada2005 RM2.5.4(28)
The same arithmetic operators are predefined for all signed integer
types defined by a signed_integer_type_definition (see 4.5, =93Operators
and Expression Evaluation=94). For modular types, these same operators
are predefined, plus bit-wise logical operators (and, or, xor, and
not). In addition, for the unsigned types declared in the language-
defined package Interfaces (see B.2), functions are defined that
provide bit-wise ****fting and rotating.




Of course, a good compiler would probably translate something like
2**X into a ****ft which is great. But what about
****ft_Arithmetic_Right or Rotate_Left? If I had to define my own, then
it probably would not be as efficient as a predefined one from
Interfaces. It would have been nice if the Ada standard guaranteed
such operations were available for user-defined modular types.

--Micronian Coder


On Jul 13, 9:03=A0am, Georg Bauhaus <rm.plus-
bug.t...@[EMAIL PROTECTED]
> wrote:
> On Sun, 2008-07-13 at 00:51 +0000, anon wrote:
> > Plus, when a programmer defines their own type in Ada, Ada adds
> > extra set of routines that are not based in hardware checks but
softwar=
e,
> > which slows a program down.
>
> I'm not sure there is some real context here. =A0There is no loss
> in speed and no cost in terms of additional checks for using
> either Unsigned_64 or "mod 2**64". (Or "mod 2**(something smaller)".)
> Below is an example to serve as one of many (really unnecessary)
> proofs that there is no overhead stemming from user defined types
> "mod 2**N". =A0(And no overhead stemming from user defined types
> in general---they are there for a reason in this real-time
> systems programming language, I should think.)
>

[Example code removed]
 




 9 Posts in Topic:
Re: Problem using Ada.Text_IO.Modular_IO
Georg Bauhaus <rm.plus  2008-07-13 18:03:31 
Re: Problem using Ada.Text_IO.Modular_IO
anon@[EMAIL PROTECTED] (  2008-07-14 02:03:45 
Re: Problem using Ada.Text_IO.Modular_IO
Georg Bauhaus <rm.dash  2008-07-14 15:12:46 
Re: Problem using Ada.Text_IO.Modular_IO
micronian2@[EMAIL PROTECT  2008-07-15 23:16:32 
Re: Problem using Ada.Text_IO.Modular_IO
anon@[EMAIL PROTECTED] (  2008-07-16 07:47:11 
Re: Problem using Ada.Text_IO.Modular_IO
micronian2@[EMAIL PROTECT  2008-07-17 09:33:45 
Re: Problem using Ada.Text_IO.Modular_IO
micronian2@[EMAIL PROTECT  2008-07-14 09:34:34 
Re: Problem using Ada.Text_IO.Modular_IO
Georg Bauhaus <rm.dash  2008-07-14 19:26:19 
Re: Problem using Ada.Text_IO.Modular_IO
micronian2@[EMAIL PROTECT  2008-07-15 23:28:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri Nov 21 14:12:05 CST 2008.