Class Natural
java.lang.Object
java.lang.Number
fj.data.Natural
- All Implemented Interfaces:
Serializable
Represents a natural number (zero, one, two, etc.)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionA function that adds two natural numbers.static final F<Natural, BigInteger> A function that returns the BigInteger value of a given Natural.A function that divides its second argument by its first.A function that divides its second argument by its first, yielding both the quotient and the remainder.static final F<BigInteger, Option<Natural>> A function that returns the natural number equal to a given BigIntegerA function that yields the remainder of division of its second argument by its first.A function that multiplies a natural number by another.static final NaturalThe natural number oneprivate static final longA function that subtracts its first argument from its second.private final BigIntegerstatic final NaturalThe natural number zero -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd two natural numbers together.Return the BigInteger value of this natural number.Divide a natural number by another.Divide a natural number by another yielding both the quotient and the remainder.doubleReturn the double value of this natural number.booleanfloatReturn the float value of this natural number.inthashCode()intintValue()Return the int value of this natural number.longReturn the long value of this natural number.Take the remainder of a natural number division.Multiply a natural number by another.natural(long i) Returns the natural number equal to the given longReturns the natural number equal to the given BigIntegerpred()Return the predecessor of this natural numberpred_()First-class predecessor function.static NaturalTakes the product of a list of natural numbers.static NaturalTakes the product of a stream of natural numbers.Subtract a natural number from another.succ()Return the successor of this natural numbersucc_()First-class successor function.static NaturalSums a list of natural numbers.static NaturalSums a stream of natural numbers.toString()Methods inherited from class Number
byteValue, shortValue
-
Field Details
-
value
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
fromBigInt
A function that returns the natural number equal to a given BigInteger -
ZERO
The natural number zero -
ONE
The natural number one -
add
-
subtract
-
multiply
-
divide
-
mod
-
divmod
-
bigIntegerValue
A function that returns the BigInteger value of a given Natural.
-
-
Constructor Details
-
Natural
-
-
Method Details
-
natural
Returns the natural number equal to the given BigInteger- Parameters:
i- A given BigInteger- Returns:
- An optional natural number, or none if the given BigInteger is less than zero.
-
natural
-
succ
Return the successor of this natural number- Returns:
- the successor of this natural number
-
succ_
-
pred
-
pred_
-
add
-
subtract
-
multiply
-
divide
-
mod
-
divmod
-
bigIntegerValue
Return the BigInteger value of this natural number.- Returns:
- the BigInteger value of this natural number.
-
longValue
-
floatValue
public float floatValue()Return the float value of this natural number.- Specified by:
floatValuein classNumber- Returns:
- the float value of this natural number.
-
doubleValue
public double doubleValue()Return the double value of this natural number.- Specified by:
doubleValuein classNumber- Returns:
- the double value of this natural number.
-
intValue
-
sum
-
product
-
sum
-
product
-
hashCode
-
equals
-
toString
-