Ada Programming/Operators

From testwiki
Revision as of 17:57, 10 May 2007 by 142.73.67.1 (talk) (Highest precedence operator)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Ada/Navigation 1

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 appropiate keyword or delimiter.

The list is sorted from lowest precedence to highest precedence.

Logical operators

and
and xy, (also keyword and)
or
or xy, (also keyword or)
xor
exclusive or (xy¯)(x¯y), (also keyword xor)

Relational operators

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

Binary adding operators

+
Add x+y, (also special character +)
-
Subtract xy, (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 xy, (also special character **)
not
logical not ¬x, (also keyword not)
abs
absolute value |x| (also keyword abs)

Shortcut operators

The shortcut operators 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.

in
element of, vartype, e.g. Template:Ada/kw I Template:Ada/kw Positive Template:Ada/kw, (also keyword Template:Ada/kw)
not in
not element of, vartype, e.g. Template:Ada/kw I Template:Ada/kw Template:Ada/kw Positive Template:Ada/kw, (also keywords Template:Ada/kw Template:Ada/kw)

See also

Wikibook

Ada 95 Reference Manual

Ada 2005 Reference Manual

Ada Quality and Style Guide

Template:Ada/Operators es:Programación en Ada / Operadores