Cryptography Reference
In-Depth Information
// Initialize a, b, and number and calculate something or other
// ...
c = number * (a+b/2)
are thus possible. The compiler takes care of calling the appropriate constructor
functions automatically and sees to it that the transformation of the integer type
number and the constant 2 into LINT objects takes place at run time, before the
operators + and * are invoked. We thereby obtain the greatest possible flexibility in
the application of the operators, with the restriction that expressions containing
objects of type LINT are themselves of type LINT and can thereafter be assigned
only to objects of type LINT .
Before we get ourselves involved in the details of the individual operators,
we would like to give an overview of the operators defined by the class LINT , for
which the reader is referred to Tables 14-2 through 14-5,
Table 14-2. LINT arithmetic operators
+
addition
++
increment (prefix and postfix operators)
-
subtraction
--
decrement (prefix and postfix operators)
*
multiplication
/
division (quotient)
%
remainder
Table 14-3. LINT bitwise operators
&
bitwise AND
|
bitwise OR
ˆ
bitwise exclusive OR (XOR)
<<
shift left
>>
shift right
We now would like to deal with the implementation of the operator functions
* ”, “ = ”, “ *= ”, a n d “ == ”, which may serve as examples of the implementation
of the LINT operators. First, with the help of the operator “ *= ” we see how
multiplication of LINT objects is carried out by the C function mul_l() .The
operator is implemented as a friend function, to which both factors associated
 
Search WWH ::




Custom Search