Ada Programming/Delimiters/*
Appearance
Operator
[edit | edit source]Standard Operations
[edit | edit source]Arithmetic Multiplication
[edit | edit source]The "*" operator is defined as arithmetic multiplication for all numeric types.
function"*" (Left, Right : T)returnT;
Usage
[edit | edit source]A :constantFloat := 5.0 * 2.0; -- A is now 10.0 B :constantInteger := 5 * 2; -- B is also 10
Working Example
[edit | edit source]withAda.Text_IO;procedureOperator_MultiplyisA :constantFloat := 5.0 * 2.0; -- A is now 10.0 B :constantInteger := 5 * 2; -- B is also 10packageT_IOrenamesAda.Text_IO;packageF_IOisnewAda.Text_IO.Float_IO (Float);packageI_IOisnewAda.Text_IO.Integer_IO (Integer);beginT_IO.Put ("A = "); F_IO.Put ( Item => A, Fore => 3, Aft => 1, Exp => 0); T_IO.New_Line; T_IO.Put ("B = "); I_IO.Put ( Item => B, Width => 3, Base => 10); T_IO.New_Line;endOperator_Multiply;
Common Non-Standard Operations
[edit | edit source]Character replication
[edit | edit source]A String is created where a single character is replicated n-times.
function"*" (Left : Natural; Right : Character)returnString;
In addition to standard Strings this operator is also defined for Bounded_String and Unbounded_String.
Usage
[edit | edit source]A : constant String := 10 * 'X'; -- A is filled with 10 X
Working Example
[edit | edit source]The character replication operator is part of the Ada.Strings.Fixed package. You need to with and use the package to make the operator visible.
withAda.Text_IO;withAda.Strings.Fixed;procedureOperator_Multiply_2isuseAda.Strings.Fixed; A :constantString := 10 * 'X'; -- A is filled with 10 XpackageT_IOrenamesAda.Text_IO;beginT_IO.Put_Line ("A = " & A);endOperator_Multiply_2;
String replication
[edit | edit source]A String is created where a source string is replicated n-times.
function"*" (Left : Natural; Right : String)returnString;
In addition to standard fixed strings this operator is also defined for Bounded_String and Unbounded_String.
Usage
[edit | edit source]A : constant String := 3 * "Hello "; -- A is filled with 3 Hello
Working Example
[edit | edit source]The string replication operator is part of the Ada.Strings.Fixed package. You need to with and use the package to make the operator visible.
withAda.Text_IO;withAda.Strings.Fixed;procedureOperator_Multiply_3isuseAda.Strings.Fixed; A :constantString := 3 * "Hello "; -- A is filled with 3 Hello.packageT_IOrenamesAda.Text_IO;beginT_IO.Put_Line ("A = " & A);endOperator_Multiply_3;
See also
[edit | edit source]Wikibook
[edit | edit source]Ada 95 Reference Manual
[edit | edit source]- 4.4 Expressions (Annotated)
- 4.5.5 Multiplying Operators (Annotated)
- A.4.3 Fixed-Length String Handling (Annotated)
- A.4.4 Bounded-Length String Handling (Annotated)
- A.4.5 Unbounded-Length String Handling (Annotated)
Ada 2005 Reference Manual
[edit | edit source]- 4.4 Expressions (Annotated)
- 4.5.5 Multiplying Operators (Annotated)
- A.4.3 Fixed-Length String Handling (Annotated)
- A.4.4 Bounded-Length String Handling (Annotated)
- A.4.5 Unbounded-Length String Handling (Annotated)
| Ada Operators | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
