Hub Nexus
Updated

AuthorNo author yetClaim it

See something to improve? Propose a change.

Support

Computing » Computer Science » Computer Programming » Ada Programming

Standard operators

Ada allows operator overloading for all standard operators and so the following summaries can only describe the suggested standard operations for each operator. It is quite possible to misuse any standard operator to perform something unusual.

Each operator is either a keyword or a delimiter—hence all operator pages are redirects to the appropriate keyword or delimiter.

Operators have arguments which in the RM are called Left and Right for binary operators, Right for unary operators (indicating the position with respect to the operator symbol).

The list is sorted from lowest precedence to highest precedence.

Logical operators

and
and x ∧ y, (also keyword and)
or
or x ∨ y, (also keyword or)
xor
exclusive or ( x ∧ \overset{¯}{y} ) ∨ ( \overset{¯}{x} ∧ y ), (also keyword xor)

Relational operators

/=
Not Equal x ≠ y, (also special character /=)
=
Equal x = y, (also special character =)
<
Less than x < y, (also special character <)
<=
Less than or equal to (x ≤ y), (also special character <=)
>
Greater than (x > y), (also special character >)
>=
Greater than or equal to (x ≥ y), (also special character >=)

Binary adding operators

+
Add x + y, (also special character +)
Subtract x − y, (also special character -)
&
Concatenate , x & y, (also special character &)

Unary adding operators

+
Plus sign + x, (also special character +)
Minus sign − x, (also special character -)

Multiplying operator

Multiply, x × y, (also special character *)
/
Divide x / y, (also special character /)
mod
modulus (also keyword mod)
rem
remainder (also keyword rem)

Highest precedence operator

**
Power {x}^{y}, (also special character **)
not
logical not ¬ x, (also keyword not)
abs
absolute value | x | (also keyword abs)

Short-circuit control forms

These are not operators and thus cannot be overloaded.

and then
e.g. if Y /= 0 and then X/Y > Limit then ...
or else
e.g. if Ptr = null or else Ptr.I = 0 then ...

Membership tests

The Membership Tests also cannot be overloaded because they are not operators.

in
element of, v a r ∈ t y p e, e.g. if I

Range membership test

if Today not in Tuesday .. Thursday then
...

Subtype membership test

Is_Non_Negative := X in Natural;

Class membership test

exit when Object in Circle'Class;

Range membership test

if Today not in Tuesday .. Thursday then
...

Choice list membership test

This language feature has been introduced in Ada 2012.

Ada 2012 extended the membership tests to include the union (short-circuit or) of several range or value choices.

if Today in Monday .. Wednesday | Friday then
...

See also

Wikibook

Ada Programming

Ada 95 Reference Manual

Ada 2005 Reference Manual

Ada Quality and Style Guide

Ada Operators
andand then>+abs&
oror else>=-mod
xor=<*remin
not/=<=**/not in

Where this page came from

This page was imported from Wikibooks. From “Ada Programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

In these publicationsAda Programming

LanguagesEnglish

Licence: CC BY-SA 4.0 · Adapted from en.wikibooks.org

1

0

0

0

Spinner Logo

Comments

Spinner Logo
Version: 2CC0 1.0 — public domain
The runaway star that left the Tarantula Nebula
Version: 2CC0 1.0 — public domain
The Blackwell School, where segregation had no law behind it
Version: 2CC0 1.0 — public domain
The Eagle Nebula, seen in the infrared
Version: 2CC0 1.0 — public domain
The house where the Equal Rights Amendment was written
Version: 2CC0 1.0 — public domain
The Aleutians, the forgotten front of the Second World War
Version: 2CC0 1.0 — public domain
The Cosmic Cliffs are not cliffs