Skip to content

Adding section on discrete numeric types #1245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ Numeric Attributes
Attributes of Modular Types
---------------------------

In the Introduction to Ada course, we've seen that Ada has two kinds of integer
type: :ref:`signed <Intro_Ada_Integers>` and
:ref:`modular <Intro_Ada_Unsigned_Types>` types. For example:

.. code:: ada compile_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1

package Num_Types is

type Signed_Integer is range 1 .. 1_000_000;
type Modular is mod 2**32;

end Num_Types;

In this section, we discuss two attributes of modular types: :ada:`Modulus`
and :ada:`Mod`. We also discuss operations on modular types.

Expand All @@ -35,10 +22,17 @@ and :ada:`Mod`. We also discuss operations on modular types.
The :ada:`Modulus` attribute returns the modulus of the modular type as a
universal integer value. Let's get the modulus of the 32-bit :ada:`Modular`
type that we've declared in the :ada:`Num_Types` package of the previous
example:
chapter:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1

package Num_Types is

type Signed_Integer is range 1 .. 1_000_000;
type Modular is mod 2**32;

end Num_Types;

with Ada.Text_IO; use Ada.Text_IO;

with Num_Types; use Num_Types;
Expand Down
Loading
Loading