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 NaturalNumberKernel
RADIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(NaturalNumber n) Addsntothis.booleanReports whetherthisis small enough to convert toint.booleanReports whethersis of the right form to convert to aNaturalNumber.intvoidCopiesntothis.voidDecrementsthis.Dividesthisbyn, returning the remainder.final booleaninthashCode()voidIncrementsthis.voidMultipliesthisbyn.voidpower(int p) Raisesthisto the powerp.voidroot(int r) Updatesthisto ther-th root of its incoming value.voidsetFromInt(int i) Sets the value ofthistoi, wheniis non-negative.voidSets the value ofthisto the number whose standard decimal representation as aStringiss, whenshas the appropriate form (i.e.,sis the result of the functiontoStringfor someNaturalNumber).voidSubtractsnfromthis.inttoInt()Reports the value ofthisas anint, whenthisis small enough.toString()Methods inherited from interface NaturalNumberKernel
divideBy10, isZero, multiplyBy10Methods inherited from interface Standard
clear, newInstance, transferFrom
-
Constructor Details
-
NaturalNumberSecondary
public NaturalNumberSecondary()
-
-
Method Details
-
equals
-
hashCode
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<NaturalNumber>
-
setFromInt
Description copied from interface:NaturalNumberSets the value ofthistoi, wheniis non-negative.- Specified by:
setFromIntin interfaceNaturalNumber- Parameters:
i- the new value
-
canConvertToInt
Description copied from interface:NaturalNumberReports whetherthisis small enough to convert toint.- Specified by:
canConvertToIntin interfaceNaturalNumber- Returns:
- true iff
thisis small enough
-
toInt
Description copied from interface:NaturalNumberReports the value ofthisas anint, whenthisis small enough.- Specified by:
toIntin interfaceNaturalNumber- Returns:
- the value
-
canSetFromString
Description copied from interface:NaturalNumberReports whethersis 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:
canSetFromStringin interfaceNaturalNumber- Parameters:
s- theStringto be converted- Returns:
- true iff
sis of the right form
-
setFromString
Description copied from interface:NaturalNumberSets the value ofthisto the number whose standard decimal representation as aStringiss, whenshas the appropriate form (i.e.,sis the result of the functiontoStringfor someNaturalNumber).- Specified by:
setFromStringin interfaceNaturalNumber- Parameters:
s- theStringto be converted
-
copyFrom
Description copied from interface:NaturalNumberCopiesntothis.- Specified by:
copyFromin interfaceNaturalNumber- Parameters:
n-NaturalNumberto copy from
-
increment
Description copied from interface:NaturalNumberIncrementsthis.- Specified by:
incrementin interfaceNaturalNumber
-
decrement
Description copied from interface:NaturalNumberDecrementsthis.- Specified by:
decrementin interfaceNaturalNumber
-
add
Description copied from interface:NaturalNumberAddsntothis.- Specified by:
addin interfaceNaturalNumber- Parameters:
n-NaturalNumberto add
-
subtract
Description copied from interface:NaturalNumberSubtractsnfromthis.- Specified by:
subtractin interfaceNaturalNumber- Parameters:
n-NaturalNumberto subtract
-
multiply
Description copied from interface:NaturalNumberMultipliesthisbyn.- Specified by:
multiplyin interfaceNaturalNumber- Parameters:
n-NaturalNumberto multiply by
-
divide
Description copied from interface:NaturalNumberDividesthisbyn, returning the remainder.- Specified by:
dividein interfaceNaturalNumber- Parameters:
n-NaturalNumberto divide by- Returns:
- remainder after division
-
power
Description copied from interface:NaturalNumberRaisesthisto the powerp.- Specified by:
powerin interfaceNaturalNumber- Parameters:
p- power to raise to
-
root
Description copied from interface:NaturalNumberUpdatesthisto ther-th root of its incoming value.- Specified by:
rootin interfaceNaturalNumber- Parameters:
r- root
-