eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Integer::ModuloNumber':

Home

everywhere
www.exept.de
for:
[back]

Class: ModuloNumber (private in Integer

This class is only visible from within Integer.

Inheritance:

   Object
   |
   +--Integer::ModuloNumber

Package:
stx:libbasic
Category:
Magnitude-Numbers
Owner:
Integer
Author:
Stefan Vogel

Description:


This is a helper class to perform fast computation of the modulus.
(with big numbers, this does make a difference)

WARNING: this does only work with numbers which have no common
         divisor (which is true for cryptographic applications).
         So, use this only if you know what you are doing ...



[instance variables:]
    modulus       the modulus
    reciprocal    reciprocal of the modulus
    shift         shift count to cut off some bits


Related information:

    Integer
    SmallInteger
    LargeInsteger

Class protocol:

instance creation
o  modulus: anInteger


Instance protocol:

accessing
o  modulus
return the modulus

o  modulus: n
set the modulus

arithmetic
o  modulusOf: aNumber
compute the aNumber modulo myself.
The shortcut works only, if aNumber is < modulo * modulo
(When doing arithmethic modulo something).
Otherwise do it the long way

converting
o  asModuloNumber


Examples:



        17 asModuloNumber modulusOf:38


        38 \\ 17


ST/X 6.1.1; WebServer 1.620 at exept:8081; Mon, 21 May 2012 18:13:29 GMT