Package components.naturalnumber
Class NaturalNumberSecondary
java.lang.Object
components.naturalnumber.NaturalNumberSecondary
- All Implemented Interfaces:
NaturalNumber
,NaturalNumberKernel
,Standard<NaturalNumber>
,Comparable<NaturalNumber>
- Direct Known Subclasses:
NaturalNumber1L
,NaturalNumber2
,NaturalNumber3
,NaturalNumber4
Layered implementations of secondary methods for
NaturalNumber
.-
Field Summary
Fields inherited from interface components.naturalnumber.NaturalNumberKernel
RADIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(NaturalNumber n) Addsn
tothis
.boolean
Reports whetherthis
is small enough to convert toint
.boolean
Reports whethers
is of the right form to convert to aNaturalNumber
.int
void
Copiesn
tothis
.void
Decrementsthis
.Dividesthis
byn
, returning the remainder.final boolean
int
hashCode()
void
Incrementsthis
.void
Multipliesthis
byn
.void
power
(int p) Raisesthis
to the powerp
.void
root
(int r) Updatesthis
to ther
-th root of its incoming value.void
setFromInt
(int i) Sets the value ofthis
toi
, wheni
is non-negative.void
Sets the value ofthis
to the number whose standard decimal representation as aString
iss
, whens
has the appropriate form (i.e.,s
is the result of the functiontoString
for someNaturalNumber
).void
Subtractsn
fromthis
.int
toInt()
Reports the value ofthis
as anint
, whenthis
is small enough.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface components.naturalnumber.NaturalNumberKernel
divideBy10, isZero, multiplyBy10
Methods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Constructor Details
-
NaturalNumberSecondary
public NaturalNumberSecondary()
-
-
Method Details
-
equals
-
hashCode
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<NaturalNumber>
-
setFromInt
Description copied from interface:NaturalNumber
Sets the value ofthis
toi
, wheni
is non-negative.- Specified by:
setFromInt
in interfaceNaturalNumber
- Parameters:
i
- the new value
-
canConvertToInt
Description copied from interface:NaturalNumber
Reports whetherthis
is small enough to convert toint
.- Specified by:
canConvertToInt
in interfaceNaturalNumber
- Returns:
- true iff
this
is small enough
-
toInt
Description copied from interface:NaturalNumber
Reports the value ofthis
as anint
, whenthis
is small enough.- Specified by:
toInt
in interfaceNaturalNumber
- Returns:
- the value
-
canSetFromString
Description copied from interface:NaturalNumber
Reports whethers
is of the right form to convert to aNaturalNumber
. Note that this is an instance method and needs to be called with a distinguished argument even though the corresponding parameter (this
) is not going to be used. This method should be a static method but currently in Java static methods cannot be declared in interfaces.- Specified by:
canSetFromString
in interfaceNaturalNumber
- Parameters:
s
- theString
to be converted- Returns:
- true iff
s
is of the right form
-
setFromString
Description copied from interface:NaturalNumber
Sets the value ofthis
to the number whose standard decimal representation as aString
iss
, whens
has the appropriate form (i.e.,s
is the result of the functiontoString
for someNaturalNumber
).- Specified by:
setFromString
in interfaceNaturalNumber
- Parameters:
s
- theString
to be converted
-
copyFrom
Description copied from interface:NaturalNumber
Copiesn
tothis
.- Specified by:
copyFrom
in interfaceNaturalNumber
- Parameters:
n
-NaturalNumber
to copy from
-
increment
Description copied from interface:NaturalNumber
Incrementsthis
.- Specified by:
increment
in interfaceNaturalNumber
-
decrement
Description copied from interface:NaturalNumber
Decrementsthis
.- Specified by:
decrement
in interfaceNaturalNumber
-
add
Description copied from interface:NaturalNumber
Addsn
tothis
.- Specified by:
add
in interfaceNaturalNumber
- Parameters:
n
-NaturalNumber
to add
-
subtract
Description copied from interface:NaturalNumber
Subtractsn
fromthis
.- Specified by:
subtract
in interfaceNaturalNumber
- Parameters:
n
-NaturalNumber
to subtract
-
multiply
Description copied from interface:NaturalNumber
Multipliesthis
byn
.- Specified by:
multiply
in interfaceNaturalNumber
- Parameters:
n
-NaturalNumber
to multiply by
-
divide
Description copied from interface:NaturalNumber
Dividesthis
byn
, returning the remainder.- Specified by:
divide
in interfaceNaturalNumber
- Parameters:
n
-NaturalNumber
to divide by- Returns:
- remainder after division
-
power
Description copied from interface:NaturalNumber
Raisesthis
to the powerp
.- Specified by:
power
in interfaceNaturalNumber
- Parameters:
p
- power to raise to
-
root
Description copied from interface:NaturalNumber
Updatesthis
to ther
-th root of its incoming value.- Specified by:
root
in interfaceNaturalNumber
- Parameters:
r
- root
-