- All Superinterfaces:
Comparable<RealNumber>
,Number
,RationalNumber
,RealNumber
- All Known Subinterfaces:
AtLeast<N>
,AtLeastEight
,AtLeastEighteen
,AtLeastEleven
,AtLeastFifteen
,AtLeastFive
,AtLeastFour
,AtLeastFourteen
,AtLeastMinusOne
,AtLeastNine
,AtLeastNineteen
,AtLeastOne
,AtLeastSeven
,AtLeastSeventeen
,AtLeastSix
,AtLeastSixteen
,AtLeastTen
,AtLeastThirteen
,AtLeastThree
,AtLeastTwelve
,AtLeastTwenty
,AtLeastTwo
,AtLeastZero
,AtMost<N>
,AtMostEight
,AtMostEighteen
,AtMostEleven
,AtMostFifteen
,AtMostFive
,AtMostFour
,AtMostFourteen
,AtMostMinusOne
,AtMostNine
,AtMostNineteen
,AtMostOne
,AtMostSeven
,AtMostSeventeen
,AtMostSix
,AtMostSixteen
,AtMostTen
,AtMostThirteen
,AtMostThree
,AtMostTwelve
,AtMostTwenty
,AtMostTwo
,AtMostZero
,FourOrEight
,NaturalNumber
,NMinus1<N>
,NPlus1<N>
,PositiveInteger
- All Known Implementing Classes:
ConcreteNumber
,Eight
,Eighteen
,Eleven
,Fifteen
,Five
,Four
,Fourteen
,MinusOne
,Nine
,Nineteen
,One
,Seven
,Seventeen
,Six
,Sixteen
,Ten
,Thirteen
,Three
,Twelve
,Twenty
,Two
,Zero
public sealed interface Integer
extends RationalNumber
permits NaturalNumber, ConcreteNumber, AtLeast<N>, AtMost<N>, NMinus1<N>, NPlus1<N>, AtLeastMinusOne, AtMostTwenty (not exhaustive)
Any integer number such as -12, 14, 0, 1 google, etc.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thisInteger
as aBigInteger
default int
Returns aStream
consisting of allInteger
s in the range from thisInteger
to the givenInteger
default One
Return the denominatordefault Integer
Returns the quotient of dividing thisInteger
by the givenInteger
default double
Returns thisRealNumber
's value with double-precision type.static boolean
Returns true if the givenInteger
s are equal, false otherwisedefault boolean
Returns true if thisInteger
is greater than the givenInteger
, false otherwisedefault boolean
Returns true if thisInteger
is greater than the givenInteger
, false otherwisedefault int
Returns the denominator as a primitive int or throws an exception if its not in the range of primitive intsdefault int
Returns the numerator as a primitive int or throws an exception if its not in the range of primitive intsint
intValue()
Returns the value of thisInteger
as a primitive int or throws an Exception if its not within int range.default boolean
Returns true if thisInteger
is less than the givenInteger
, false otherwisedefault boolean
Returns true if thisInteger
is less than the givenInteger
, false otherwisedefault long
Returns the denominator as a primitive long or throws an Exception if its not in the range of primitive longsdefault long
Returns the numerator as a primitive long or throws an Exception if its not in the range of primitive longslong
Returns the value of thisInteger
as a primitive long or throws an Exception if its not within the range of long ints.default Integer
Returns the difference between thisInteger
and the givenInteger
default Integer
Returns the remainder of dividing thisInteger
by the givenInteger
default Integer
Return the numeratorstatic Integer
of
(int i) Returns anInteger
whose value is the givenint
static Integer
of
(long i) Returns anInteger
whose value is the givenlong
static Integer
of
(BigInteger value) Creates a newInteger
whose value is the givenBigInteger
static Integer
Creates a newInteger
from the given string or throws anException
if the string does not represent aInteger
.default Integer
Returns the sum of thisInteger
and the givenInteger
default Integer
Returns the product of thisInteger
and the givenInteger
static String
Returns a binary string representation of the givenInteger
Methods inherited from interface org.zfcj.math.numbers.RationalNumber
dividedBy, isInt, isLong, minus, plus, reduce, times
Methods inherited from interface org.zfcj.math.numbers.RealNumber
abs, almostEquals, almostEquals, bigDecimalValue, dividedBy, greaterThan, greaterThanOrEqualTo, isDouble, lessThan, lessThanOrEqualTo, minus, modulo, plus, pow, times, truncate
-
Method Details
-
intValue
int intValue()Returns the value of thisInteger
as a primitive int or throws an Exception if its not within int range.- Returns:
- an int that represents this integer
-
longValue
long longValue()Returns the value of thisInteger
as a primitive long or throws an Exception if its not within the range of long ints.- Returns:
- a long that represents this integer
-
bigIntegerValue
BigInteger bigIntegerValue()Returns the value of thisInteger
as aBigInteger
- Returns:
- this
Integer
'sBigInteger
value
-
numerator
Description copied from interface:RationalNumber
Return the numerator- Specified by:
numerator
in interfaceRationalNumber
- Returns:
- the numerator
-
denominator
Description copied from interface:RationalNumber
Return the denominator- Specified by:
denominator
in interfaceRationalNumber
- Returns:
- the denominator
-
intNumerator
default int intNumerator()Description copied from interface:RationalNumber
Returns the numerator as a primitive int or throws an exception if its not in the range of primitive ints- Specified by:
intNumerator
in interfaceRationalNumber
- Returns:
- the numerator as an int
-
intDenominator
default int intDenominator()Description copied from interface:RationalNumber
Returns the denominator as a primitive int or throws an exception if its not in the range of primitive ints- Specified by:
intDenominator
in interfaceRationalNumber
- Returns:
- the numerator as an int
-
longNumerator
default long longNumerator()Description copied from interface:RationalNumber
Returns the numerator as a primitive long or throws an Exception if its not in the range of primitive longs- Specified by:
longNumerator
in interfaceRationalNumber
- Returns:
- the numerator as an long
-
longDenominator
default long longDenominator()Description copied from interface:RationalNumber
Returns the denominator as a primitive long or throws an Exception if its not in the range of primitive longs- Specified by:
longDenominator
in interfaceRationalNumber
- Returns:
- the denominator as an long
-
doubleValue
default double doubleValue()Description copied from interface:RealNumber
Returns thisRealNumber
's value with double-precision type. Note that the value will be an approximation for irrational numbers such as Pi, Phi, e or repeating decimals such as 0.666..., 1.851851851..., etc.- Specified by:
doubleValue
in interfaceRealNumber
- Returns:
- the double value that is the closest approximation to this real number
-
plus
Returns the sum of thisInteger
and the givenInteger
- Parameters:
i
- the integer to sum- Returns:
- the sum of integers
-
minus
Returns the difference between thisInteger
and the givenInteger
- Parameters:
i
- the integer to subtract- Returns:
- the difference of integers
-
times
Returns the product of thisInteger
and the givenInteger
- Parameters:
i
- the integer to multiply- Returns:
- the product of integers
-
divide
Returns the quotient of dividing thisInteger
by the givenInteger
- Parameters:
i
- the integer to divide by- Returns:
- the quotient of integers
-
modulo
Returns the remainder of dividing thisInteger
by the givenInteger
- Parameters:
i
- the integer to modulo by- Returns:
- the remainder of dividing integers
-
lessThan
Returns true if thisInteger
is less than the givenInteger
, false otherwise- Parameters:
i
- the integer to test- Returns:
- the truth of this integer being less than the given integer
-
lessThanOrEqualTo
Returns true if thisInteger
is less than the givenInteger
, false otherwise- Parameters:
i
- the integer to test- Returns:
- the truth of this integer being less than or equal to the given integer
-
greaterThan
Returns true if thisInteger
is greater than the givenInteger
, false otherwise- Parameters:
i
- the integer to test- Returns:
- the truth of this integer being greater than the given integer
-
greaterThanOrEqualTo
Returns true if thisInteger
is greater than the givenInteger
, false otherwise- Parameters:
i
- the integer to test- Returns:
- the truth of this integer being greater than or equal to the given integer
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RealNumber>
- Specified by:
compareTo
in interfaceRealNumber
-
countTo
Returns aStream
consisting of allInteger
s in the range from thisInteger
to the givenInteger
- Parameters:
i
- theInteger
to count to- Returns:
- a stream of
Integers
s
-
of
Returns anInteger
whose value is the givenint
- Parameters:
i
- the int value- Returns:
- an
Integer
with value i
-
of
Returns anInteger
whose value is the givenlong
- Parameters:
i
- the long value- Returns:
- an
Integer
with value i
-
of
Creates a newInteger
whose value is the givenBigInteger
- Parameters:
value
- theBigInteger
value- Returns:
- an
Integer
with the given value
-
equals
Returns true if the givenInteger
s are equal, false otherwise- Parameters:
a
- the first integerb
- the second integer- Returns:
- true if the integers are equal, otherwise false
-
toBinaryString
Returns a binary string representation of the givenInteger
- Parameters:
i
- theInteger
- Returns:
- a binary string representation of the
Integer
-
parse
Creates a newInteger
from the given string or throws anException
if the string does not represent aInteger
.- Parameters:
s
- the "integer" string- Returns:
- an
Integer
that represents the given string
-