Squeak Class Documentation category index | class index  
 
LargePositiveInteger
  category: Kernel-Numbers
  superclass: Integer
  subclasses: LargeNegativeInteger

I represent positive integers of more than 30 bits (ie, >= 1073741824). These values are beyond the range of SmallInteger, and are encoded here as an array of 8-bit digits. Care must be taken, when new values are computed, that any result that COULD BE a SmallInteger IS a SmallInteger (see normalize).

Note that the bit manipulation primitives, bitAnd:, bitShift:, etc., = and ~= run without failure (and therefore fast) if the value fits in 32 bits. This is a great help to the simulator.

instance methods
  arithmetic
  *
+
-
/
//
\\
\\\
abs
negated
quo:

  bit manipulation
  bitAnd:
bitOr:
bitShift:
bitXor:
hashMultiply
highBit
highBitOfMagnitude

  comparing
  <
<=
=
>
>=
~=

  converting
  normalize

  system primitives
  digitAt:
digitAt:put:
digitLength
replaceFrom:to:with:startingAt:

  testing
  negative
positive
sign
strictlyPositive

class methods
  testing
  initializedInstance
test:

instance methods
  arithmetic top  
 

*

Primitive. Multiply the receiver by the argument and answer with an
Integer result. Fail if either the argument or the result is not a
SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824). Optional. See
Object documentation whatIsAPrimitive.


 

+

Primitive. Add the receiver to the argument and answer with an
Integer result. Fail if either the argument or the result is not a
SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824). Optional. See
Object documentation whatIsAPrimitive.


 

-

Primitive. Subtract the argument from the receiver and answer with an
Integer result. Fail if either the argument or the result is not a
SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824). Optional. See
Object documentation whatIsAPrimitive.


 

/

Primitive. Divide the receiver by the argument and answer with the
result if the division is exact. Fail if the result is not a whole integer.
Fail if the argument is 0. Fail if either the argument or the result is not
a SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824). Optional. See
Object documentation whatIsAPrimitive.


 

//

Primitive. Divide the receiver by the argument and return the result.
Round the result down towards negative infinity to make it a whole
integer. Fail if the argument is 0. Fail if either the argument or the
result is not a SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824).
Optional. See Object documentation whatIsAPrimitive.


 

\\

Primitive. Take the receiver modulo the argument. The result is the
remainder rounded towards negative infinity, of the receiver divided
by the argument. Fail if the argument is 0. Fail if either the argument
or the result is not a SmallInteger or a LargePositiveInteger less than
2-to-the-30th (1073741824). Optional. See Object documentation whatIsAPrimitive.


 

\\\

a faster modulo method for use in DSA. Be careful if you try to use this elsewhere


 

abs

Answer a Number that is the absolute value (positive magnitude) of the
receiver.


 

negated

Answer a Number that is the negation of the receiver.


 

quo:

Primitive. Divide the receiver by the argument and return the result.
Round the result down towards zero to make it a whole integer. Fail if
the argument is 0. Fail if either the argument or the result is not a
SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824). Optional. See
Object documentation whatIsAPrimitive.


  bit manipulation top  
 

bitAnd:

Primitive. Answer an Integer whose bits are the logical AND of the
receiver's bits and those of the argument. Fail if the receiver or argument
is greater than 32 bits. See Object documentation whatIsAPrimitive.


 

bitOr:

Primitive. Answer an Integer whose bits are the logical OR of the
receiver's bits and those of the argument. Fail if the receiver or argument
is greater than 32 bits. See Object documentation whatIsAPrimitive.


 

bitShift:

Primitive. Answer an Integer whose value (in twos-complement
representation) is the receiver's value (in twos-complement
representation) shifted left by the number of bits indicated by the
argument. Negative arguments shift right. Zeros are shifted in from the
right in left shifts. The sign bit is extended in right shifts.
Fail if the receiver or result is greater than 32 bits.
See Object documentation whatIsAPrimitive.


 

bitXor:

Primitive. Answer an Integer whose bits are the logical XOR of the
receiver's bits and those of the argument. Fail if the receiver or argument
is greater than 32 bits. See Object documentation whatIsAPrimitive.


 

hashMultiply

Truncate to 28 bits and try again


 

highBit

Answer the index of the high order bit of the receiver, or zero if the
receiver is zero. Raise an error if the receiver is negative, since
negative integers are defined to have an infinite number of leading 1's
in 2's-complement arithmetic. Use >>highBitOfMagnitude if you want to
get the highest bit of the magnitude.


 

highBitOfMagnitude

Answer the index of the high order bit of the magnitude of the
receiver, or zero if the receiver is zero.
This method is used for LargeNegativeIntegers as well,
since Squeak's LargeIntegers are sign/magnitude.


  comparing top  
 

<

Primitive. Compare the receiver with the argument and answer true if
the receiver is less than the argument. Otherwise answer false. Fail if the
argument is not a SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824).
Optional. See Object documentation whatIsAPrimitive.


 

<=

Primitive. Compare the receiver with the argument and answer true if
the receiver is less than or equal to the argument. Otherwise answer false.
Fail if the argument is not a SmallInteger or a LargePositiveInteger less
than 2-to-the-30th (1073741824). Optional. See Object documentation whatIsAPrimitive.


 

=

Primitive. Compare the receiver with the argument and answer true if
the receiver is equal to the argument. Otherwise answer false. Fail if the
receiver or argument is negative or greater than 32 bits.
Optional. See Object documentation whatIsAPrimitive.


 

>

Primitive. Compare the receiver with the argument and answer true if
the receiver is greater than the argument. Otherwise answer false. Fail if
the argument is not a SmallInteger or a LargePositiveInteger less than
2-to-the-30th (1073741824). Optional. See Object documentation whatIsAPrimitive.


 

>=

Primitive. Compare the receiver with the argument and answer true if
the receiver is greater than or equal to the argument. Otherwise answer
false. Fail if the argument is not a SmallInteger or a LargePositiveInteger
less than 2-to-the-30th (1073741824). Optional. See Object documentation whatIsAPrimitive.


 

~=

Primitive. Compare the receiver with the argument and answer true if
the receiver is equal to the argument. Otherwise answer false. Fail if the
receiver or argument is negative or greater than 32 bits.
Optional. See Object documentation whatIsAPrimitive.


  converting top  
 

normalize

Check for leading zeroes and return shortened copy if so


  system primitives top  
 

digitAt:

Primitive. Answer the value of an indexable field in the receiver. LargePositiveInteger uses bytes of base two number, and each is a 'digit' base 256. Fail if the argument (the index) is not an Integer or is out of bounds. Essential. See Object documentation whatIsAPrimitive.


 

digitAt:put:

Primitive. Store the second argument (value) in the indexable field of
the receiver indicated by index. Fail if the value is negative or is larger
than 255. Fail if the index is not an Integer or is out of bounds. Answer
the value that was stored. Essential. See Object documentation
whatIsAPrimitive.


 

digitLength

Primitive. Answer the number of indexable fields in the receiver. This
value is the same as the largest legal subscript. Essential. See Object
documentation whatIsAPrimitive.


 

replaceFrom:to:with:startingAt:

Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.


  testing top  
 

negative

Answer whether the receiver is mathematically negative.


 

positive

Answer whether the receiver is positive or equal to 0. (ST-80 protocol).
See also strictlyPositive


 

sign

Optimization. Answer 1 since receiver is greater than 0.


 

strictlyPositive

Answer whether the receiver is mathematically positive.


class methods
  testing top  
 

initializedInstance

Answer an instance of the receiver which in some sense is initialized. In the case of Morphs, this will yield an instance that can be attached to the Hand after having received the same kind of basic initialization that would be obtained from an instance chosen from the 'new morph' menu. Return nil if the receiver is reluctant for some reason to return such a thing


 

test:

Time millisecondsToRun: [LargePositiveInteger test: 100] 1916