Quantcast
Channel: Ada -- What Is A Modular Type - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by ajb for Ada -- What Is A Modular Type

$
0
0

** is the exponentiation operator. That is, A**B means AB.

mod, in this context, is just the syntax you use to tell it you're defining a modular type. In this case, it means that this is an integer type whose values range from 0 to 2Standard'Storage_Unit - 1. Standard'Storage_Unit isn't defined by the language, but is defined by the Ada compiler you're using (the language allows compilers to define their own attributes); I believe it equals System.Storage_Unit. This is a constant that defines the number of bits in an addressable storage unit. This constant is 8 for the vast majority of processors (since each address addresses one 8-bit byte), but there are exceptions.

So what this does is define an integer type whose values range from 0 to 255 (on most processors), i.e. the integers that will fit in a byte. Since it's "modular", that also means that arithmetic operations on the type wrap around (i.e. if you add 130 + 130, you will get 4, and Constraint_Error will not be raised). Modular types also have bitwise operators and, or, and xor defined for them.


Viewing all articles
Browse latest Browse all 2

Trending Articles