ada

Issues in Ada Concurrency

Hi I need some help and also some insight. This is a program in Ada-2005 which has 3 tasks. The output is 'z'. If the 3 tasks do not happen in the order of their placement in the program then output can vary from z = 2, z = 1 to z = 0 ( That is easy to see in the program, mutual exclusion is attempted to make sure output is z = 2). WIT...

Optimizing mathematics on arrays of floats in Ada 95 with GNAT

Consider the bellow code. This code is supposed to be processing data at a fixed rate, in one second batches, It is part of an overal system and can't take up too much time. When running over 100 lots of 1 seconds worth of data the program takes 35 seconds (or 35%), executing this function in a loop. The test loop is timed specifically ...

The Benefits of Constants

I understand one of the big deals about constants is that you don't have to go through and update code where that constant is used all over the place. Thats great, but let's say you don't explicitly declare it as a constant. What benefit(s) exist(s) to take a variable that HAPPENS to actually not be changed and make it a constant, will t...

In Ada how do I initialise an array constant with a repeated number?

I need an array of 820 zeros for using with a mathematical function. In C I could just write the following and the compiler would fill the array: const float EMPTY_NUMBER_A[820] = { 0.0, }; However in Ada that isn't possible. I really don't want to hard code the 820 elements as 0.0. Is there a way to get the compiler to do it? typ...

Doubts in ada language

HI all, I am a beginner in the ada language.I have an short piece of code.Can anyone please tel me what does it mean? type Myarr_Type is array (Character) of Character; Myarr : Myarr_Type; C1 : character := character'first; C2 : character := character'last; My question is 1)What does C1 and C2 contain according to the above c...

gnat programming studio auto fix issues

hi, I'm using GNAT Programming Studio to update some ada files. I have a style check, which for these old files produces literally thousands of warnings. Helpfully GPS has a little auto fix 'wrench' icon in the locations view, that's great but I don't want to go through and click the wrench ten thousand times. Is there a way to have i...

C or Ada for engineering computations?

Hi,as an engineer I currently use C to write programs dealing with numerical methods. I like C as it's very fast. I don't want to move to C++ and I have been reading a bit about Ada which has some very good sides. I believe that much of the software in big industries have been or more correctly were written in Ada. I would like to know...

Can anyone please tell me the use of pragma statements

Can anyone please tell me the use of pragma in C and Ada, with some examples if possible. ...

Unchecked_Conversion in Ada

Can anyone please make me clear about the use of unchecked conversion in the Ada language.I had tried the pdf and net but all doesnt give me a clear picture to me. Now i have a small piece of code shown below: subtype Element4_Range is integer range 1..4; subtype Element3_Range is integer range 1..3; subtype Myarr_Range i...

Derived types and sub types in Ada

What are the differences? ...

double precision in Ada?

Hi, I'm very new to Ada and was trying to see if it offers double precision type. I see that we have float and Put( Integer'Image( Float'digits ) ); on my machine gives a value of 6, which is not enough for numerical computations. Does Ada has double and long double types as in C? Thanks a lot... ...

Loops in ada and the implementation

Below is a piece of code shown and doubts are regarding the implementation of loops C := character'last; --'// SO code colorizer hack I := 1; K : loop Done := C = character'first; --' Count2 := I; Exit K when Done; C := ...

Convert the ada code to its C .

I have a piece of ada code shown below which is a simple switch case statements.Is there any better way to convert this into C. for I in 1..100 loop case I is when 100 => Dollars := Dollars + 1; when 25|50|75 => Quarters := Quarters + 1; ...

The use of mod operators in ada

Hi all, Can anyone please tell me the usage of the following declarations shown below.I am a beginner in ada language.I had tried the internet but that was not clear enough. type Unsigned_4 is mod 2 ** 4; for Unsigned_4'Size use 4; ...

address representation in ada

Hi all, I have pasted a code below which is in Ada language.I need some clarification on some implementations. C : character; Char : character; type Myarr_Type is array (character range 'A'..'K') of character; Myarr : Myarr_Type := ('A','B','C','D','E','F','G','H','I','J','K'); Next_Address := Myarr'address --' Last_Addr...

Creating Ada record with one field

I've define a type: type Foo is record bar : Positive; end record; I want to create a function that returns an instance of the record: function get_foo return Foo is return (1); end get_foo; But Ada won't let me, saying "positional aggregate cannot have one argument". Stupidly trying, I've added another dumb field to the rec...

Ada with Visual studio

Hi, I'm just starting to learn Ada and was wondering if an editor like MVS 2008/2010 can be used? Will MVS detect the GNAT compiler? I have the GNAT GPL compiler but find the GPS editor hard to use (much less intuitive than the MVS editor). The tutorial doesn't explain well how to create a project in GPS. I'm currently using AdaGIDE whi...

How to print the address an ada access variable points to?

I want to print the address of an access variable (pointer) for debugging purposes. type Node is private; type Node_Ptr is access Node; procedure foo(n: in out Node_Ptr) is package Address_Node is new System.Address_To_Access_Conversions(Node); use Address_Node; begin Put_Line("node at address " & System.Address_Image(To_A...

Doubts in ada language involving procedures

I am a beginner in Ada and I have come across a piece of code which is shown below: procedure Null_Proc is begin null; end; Now as per my knowledge the procedure in Ada doesn't return anything. My doubt is what does this procedure Null_proc do? I mean I am no...

How to convert a Ada.Real_TIme.Time to a string?

I would like to write a Ada.Real_Time.Time in a file, How can I do that? Thanks ...