Cryptography Reference
In-Depth Information
The representation of large numbers that has been chosen for our class is an
extension of the representation presented in Part I for the C language. We take
from there the arrangement of the digits of a natural number as a vector of
clint values, where more-significant digits occupy the places of higher index
(cf. Chapter 2). The memory required for this is automatically allocated when an
object is generated. This is carried out by the constructors, which are invoked
either explicitly by the program or implicitly by the compiler using the allocation
function new() . In the class declaration we therefore require a variable of type
clint *n_l , to which is associated within one of the constructor functions a
pointer to the memory allocated there.
The variable status is used to keep track of various states that can be taken
by LINT objects. For example, with status , an overflow or underflow (cf. page 20)
can be reported if such an event occurs as a result of operations on LINT objects
that would result in the status variable being assigned the value E_LINT_OFL or
E_LINT_UFL . Furthermore, we would like to determine whether a LINT object has
been initialized, that is, whether any numerical value at all has been assigned to
it, before it is used in a numerical expression on the right side of the equal sign.
If a LINT object does not possess a numerical value, then status contains the
value E_LINT_INV , which all functions must check before an operation is executed.
We shall organize our LINT functions and operators in such a way that an error
message results if the value of a LINT object, and consequently the value of an
expression, is undefined.
The variable status is, strictly speaking, not an element of our numerical
representation. It serves rather for reporting and handling error states. The types
and mechanisms of error handling are discussed in detail in Chapter 16.
The class LINT defines the following two elements for representing numbers
and storing the states of objects:
clint* n_l;
int status;
Since we are dealing here with private elements, access to these class elements is
possible only by means of member or friend functions or operators. In particular,
there is no possibility of direct access to the individual digits of a number
represented by a LINT object.
14.2 Constructors
Constructors are functions for the generation of objects of a particular class. For
the LINT class this can occur with or without initialization, where in the latter case
an object is created and the required memory for the storage of the number is
allocated, but no value is assigned to the object. The constructor required for this
 
Search WWH ::




Custom Search