File tree Expand file tree Collapse file tree 2 files changed +605
-25
lines changed
content/courses/advanced-ada/parts/data_types Expand file tree Collapse file tree 2 files changed +605
-25
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,6 @@ Numeric Attributes
8
8
Attributes of Modular Types
9
9
---------------------------
10
10
11
- In the Introduction to Ada course, we've seen that Ada has two kinds of integer
12
- type: :ref: `signed <Intro_Ada_Integers >` and
13
- :ref: `modular <Intro_Ada_Unsigned_Types >` types. For example:
14
-
15
- .. code :: ada compile_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1
16
-
17
- package Num_Types is
18
-
19
- type Signed_Integer is range 1 .. 1_000_000;
20
- type Modular is mod 2**32;
21
-
22
- end Num_Types;
23
-
24
11
In this section, we discuss two attributes of modular types: :ada: `Modulus `
25
12
and :ada: `Mod `. We also discuss operations on modular types.
26
13
@@ -35,10 +22,17 @@ and :ada:`Mod`. We also discuss operations on modular types.
35
22
The :ada: `Modulus ` attribute returns the modulus of the modular type as a
36
23
universal integer value. Let's get the modulus of the 32-bit :ada: `Modular `
37
24
type that we've declared in the :ada: `Num_Types ` package of the previous
38
- example :
25
+ chapter :
39
26
40
27
.. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1
41
28
29
+ package Num_Types is
30
+
31
+ type Signed_Integer is range 1 .. 1_000_000;
32
+ type Modular is mod 2**32;
33
+
34
+ end Num_Types;
35
+
42
36
with Ada.Text_IO; use Ada.Text_IO;
43
37
44
38
with Num_Types; use Num_Types;
You can’t perform that action at this time.
0 commit comments