Package io.github.ad417.BreakInfinity
Class BigDouble
java.lang.Object
io.github.ad417.BreakInfinity.BigDouble
- All Implemented Interfaces:
Comparable<BigDouble>
A BigDouble's value is simply mantissa * 10 ^ exponent.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigDouble
The BigDouble value representing a numerical error in either parsing or mathematical operations.static final BigDouble
The singular canonical representation of a negative number too small to represent using a BigDouble.static final BigDouble
The BigDouble value for 1.0.static final BigDouble
The singular canonical representation of a number too large to represent using a BigDouble.static final BigDouble
The singular canonical value representing 0.0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabs()
static BigDouble
abs
(double value) static BigDouble
static BigDouble
double
absLog10()
static double
absLog10
(double value) static double
static double
double
acosh()
static double
acosh
(double value) static double
static double
add
(double other) Adds two numbers together, returning the result as a BigDouble.static BigDouble
affordArithmeticSeries
(BigDouble resourcesAvailable, BigDouble priceStart, BigDouble priceAdd, int currentOwned) If you're willing to spend 'resourcesAvailable' and want to buy something with additively increasing cost each purchase (start at priceStart, add by priceAdd, already own currentOwned), how much of it can you buy?static BigDouble
affordGeometricSeries
(BigDouble resourcesAvailable, double priceStart, double priceRatio, long currentOwned) static BigDouble
affordGeometricSeries
(BigDouble resourcesAvailable, BigDouble priceStart, BigDouble priceRatio, long currentOwned) If you're willing to spend 'resourcesAvailable' and want to buy something with exponentially increasing cost each purchase (start at priceStart, multiply by priceRatio, already own currentOwned), how much of it can you buy? Adapted from Trimps source code.ascensionPenalty
(int ascensions) Joke function from Realm Grinderdouble
asinh()
static double
asinh
(double value) static double
static double
double
atanh()
static double
atanh
(double value) static double
static double
cbrt()
static BigDouble
cbrt
(double value) static BigDouble
static BigDouble
ceil()
static BigDouble
ceil
(double value) static BigDouble
static BigDouble
int
int
cmp_tolerance
(BigDouble other, BigDouble tolerance) int
compare_tolerance
(BigDouble other, BigDouble tolerance) int
cosh()
static BigDouble
cosh
(double value) static BigDouble
static BigDouble
cube()
static BigDouble
cube
(double value) static BigDouble
static BigDouble
div
(double other) Divides this BigDouble by the provided value, returning the result as a BigDouble.divide
(double other) divideBy
(double other) dividedBy
(double other) double
e()
static BigDouble
efficiencyOfPurchase
(BigDouble cost, BigDouble currentRpS, BigDouble deltaRpS) When comparing two purchases that cost (resource) and increase your resource/sec by (deltaRpS), the lowest efficiency score is the better one to purchase.egg()
Joke function from Cookie Clicker.boolean
eq
(double other) boolean
boolean
boolean
eq_tolerance
(BigDouble other, BigDouble tolerance) boolean
equals
(double other) boolean
boolean
boolean
boolean
equals_tolerance
(BigDouble other, BigDouble tolerance) exp()
static BigDouble
exp
(double value) static BigDouble
static BigDouble
floor()
static BigDouble
floor
(double value) static BigDouble
static BigDouble
long
Get this BigDouble's exponent.double
Get this BigDouble's mantissa.boolean
greaterThan
(double other) boolean
greaterThan
(BigDouble other) boolean
greaterThan
(String other) boolean
greaterThanOrEqualTo
(double other) boolean
greaterThanOrEqualTo
(BigDouble other) boolean
greaterThanOrEqualTo
(String other) boolean
gt
(double other) boolean
boolean
boolean
gt_tolerance
(BigDouble other, BigDouble tolerance) boolean
gte
(double other) boolean
boolean
boolean
gte_tolerance
(BigDouble other, BigDouble tolerance) int
hashCode()
static boolean
Determine if a BigDouble is not Infinite.static boolean
isInfinite
(BigDouble value) Determine if a BigDouble is Infinite.static boolean
Check if a BigDouble is Not a Number (NaN).static boolean
isNegativeInfinity
(BigDouble value) Determine if a BigDouble is Negative Infinity.static boolean
isPositiveInfinity
(BigDouble value) Determine if a BigDouble is Positive Infinity.boolean
lessThan
(double other) boolean
boolean
boolean
lessThanOrEqualTo
(double other) boolean
lessThanOrEqualTo
(BigDouble other) boolean
lessThanOrEqualTo
(String other) double
ln()
static double
ln
(double value) static double
static double
double
log()
double
log
(double base) double
log10()
static double
log10
(double value) static double
static double
double
log2()
double
double
logarithm
(double base) static double
boolean
lt
(double other) boolean
boolean
boolean
lt_tolerance
(BigDouble other, BigDouble tolerance) boolean
lte
(double other) boolean
boolean
boolean
lte_tolerance
(BigDouble other, BigDouble tolerance) double
m()
static void
double
mantissaWithDecimalPlaces
(int places) max
(double other) min
(double other) minus
(double other) mul
(double other) Multiply two numbers together, returning the result as a BigDouble.multiply
(double other) neg()
static BigDouble
neg
(double value) static BigDouble
static BigDouble
negate()
static BigDouble
negate
(double value) static BigDouble
static BigDouble
negated()
static BigDouble
negated
(double value) static BigDouble
static BigDouble
boolean
neq
(double other) boolean
boolean
boolean
neq_tolerance
(BigDouble other, BigDouble tolerance) boolean
notEquals
(double other) boolean
boolean
boolean
notEquals_tolerance
(BigDouble other, BigDouble tolerance) static BigDouble
parseBigDouble
(String value) Parse a String that is either a valid Number or of the form X.XXeYYY for some values X.XX and YYY.double
pLog10()
static double
pLog10
(double value) static double
static double
plus
(double other) pow
(double power) static BigDouble
pow10
(double value) static BigDouble
pow10
(long value) static BigDouble
static BigDouble
randomDecimalForTesting
(long absMaxExponent) recip()
Returns the reciprocal of this value.static BigDouble
recip
(double value) static BigDouble
static BigDouble
reciprocal
(double value) static BigDouble
reciprocal
(String value) static BigDouble
reciprocate
(double value) static BigDouble
reciprocate
(String value) round()
Returns the closest long to the argument, with ties rounding to positive infinity.static BigDouble
round
(double value) static BigDouble
static BigDouble
double
sgn()
static double
sgn
(double value) static double
static double
double
sign()
static double
sign
(double value) static double
static double
double
signum()
static double
signum
(double value) static double
static double
sinh()
static BigDouble
sinh
(double value) static BigDouble
static BigDouble
sqr()
static BigDouble
sqr
(double value) static BigDouble
static BigDouble
sqrt()
static BigDouble
sqrt
(double value) static BigDouble
static BigDouble
sub
(double other) Subtracts the provided value from this BigDouble, returning the result as a BigDouble.subtract
(double other) static BigDouble
sumArithmeticSeries
(int numItems, BigDouble priceStart, BigDouble priceAdd, int currentOwned) How much resource would it cost to buy (numItems) items if you already have currentOwned, the initial price is priceStart and it adds priceAdd each purchase? Adapted from ...static BigDouble
sumGeometricSeries
(int numItems, BigDouble priceStart, BigDouble priceRatio, int currentOwned) How much resource would it cost to buy (numItems) items if you already have currentOwned, the initial price is priceStart and it multiplies by priceRatio each purchase?tanh()
static BigDouble
tanh
(double value) static BigDouble
static BigDouble
times
(double other) double
toDouble()
toExponential
(int places) toPrecision
(int places) toString()
trunc()
Returns the smallest magnitude (closest to zero) BigDouble value that is less than or equal to the argument and is equal to a mathematical integer.static BigDouble
trunc
(double value) static BigDouble
static BigDouble
truncate()
static BigDouble
truncate
(double value) static BigDouble
static BigDouble
-
Field Details
-
ZERO
The singular canonical value representing 0.0. -
ONE
The BigDouble value for 1.0. -
NaN
The BigDouble value representing a numerical error in either parsing or mathematical operations. -
POSITIVE_INFINITY
The singular canonical representation of a number too large to represent using a BigDouble. -
NEGATIVE_INFINITY
The singular canonical representation of a negative number too small to represent using a BigDouble.
-
-
Constructor Details
-
BigDouble
public BigDouble(double mantissa, long exponent) Create a BigDouble by specifying the mantissa and exponent seperately.- Parameters:
mantissa
- A floating-point number between [1, 10) OR exactly 0. Other values will be normalized to within this range.exponent
- A long number of any value. Represents the exponent.
-
BigDouble
-
BigDouble
public BigDouble(double value) Create a BigDouble from a primitive number.- Parameters:
value
- a number to convert to a BigDouble.
-
BigDouble
Create a BigDouble from a properly formatted- Parameters:
value
- A String of the form X.XXeYYY, where X.XX is the mantissa and YYY is the exponent.
-
-
Method Details
-
isNaN
Check if a BigDouble is Not a Number (NaN).- Parameters:
value
- A BigDouble to check.- Returns:
- Whether the value is NaN.
-
isPositiveInfinity
Determine if a BigDouble is Positive Infinity.- Parameters:
value
- A BigDouble to check.- Returns:
- Whether the value is Positive Infinity.
-
isNegativeInfinity
Determine if a BigDouble is Negative Infinity.- Parameters:
value
- A BigDouble to check.- Returns:
- Whether the value is Negative Infinity.
-
isInfinite
Determine if a BigDouble is Infinite.- Parameters:
value
- A BigDouble to check.- Returns:
- Whether the value is Infinite.
-
isFinite
Determine if a BigDouble is not Infinite.- Parameters:
value
- A BigDouble to check.- Returns:
- Whether the value is not Infinite.
-
parseBigDouble
Parse a String that is either a valid Number or of the form X.XXeYYY for some values X.XX and YYY.- Parameters:
value
- A string to parse into a BigDouble- Returns:
- A BigDouble equivalent to the value provided.
- Throws:
RuntimeException
- if the string is malformed or invalid.
-
getMantissa
public double getMantissa()Get this BigDouble's mantissa. A double with absolute value between [1, 10) OR exactly 0.- Returns:
- The mantissa.
-
getExponent
public long getExponent()Get this BigDouble's exponent. A long value.- Returns:
-
m
public double m()- Returns:
- The Mantissa.
- See Also:
-
e
public double e()- Returns:
- The Exponent
- See Also:
-
abs
- Returns:
- A positive BigDouble with equivalent magnitude to this BigDouble.
-
abs
- Parameters:
value
- A value to take the absolute value of.- Returns:
- A positive BigDouble with equivalent magnitude to this value.
- See Also:
-
abs
- Parameters:
value
- A value to take the absolute value of.- Returns:
- A positive BigDouble with equivalent magnitude to this value.
- See Also:
-
abs
- Parameters:
value
- A value to take the absolute value of.- Returns:
- A positive BigDouble with equivalent magnitude to this value.
- See Also:
-
neg
- Returns:
- A BigDouble with equivalent magnitude to this value but the opposite sign. value.neg().signum() == -value.signum()
-
neg
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
neg
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
neg
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
negate
-
negate
- See Also:
-
negate
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
negate
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
negated
- See Also:
-
negated
-
negated
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
negated
- Parameters:
value
- A value to negate.- Returns:
- A negated BigDouble.
- See Also:
-
signum
public double signum()- Returns:
- the signum function of the BigDouble; zero if the argument is zero,
1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
Special Cases:
- If the argument is NaN, then the result is NaN.
-
signum
-
signum
public static double signum(double value) -
signum
-
sign
public double sign()- See Also:
-
sign
-
sign
public static double sign(double value) -
sign
-
sgn
public double sgn()- See Also:
-
sgn
-
sgn
public static double sgn(double value) -
sgn
-
round
Returns the closest long to the argument, with ties rounding to positive infinity. Special cases:- If the argument is NaN, the result is NaN.
- If the argument is negative infinity or any value less than or equal to -1 * 10 ^ 17 the result is itself.
- If the argument is positive infinity or any value greater than or equal to 1 * 10 ^ 17 the result is itself.
- Returns:
- the value of the BigDouble rounded to the nearest whole number.
-
round
-
round
-
round
-
floor
- Returns:
- the largest (closest to positive infinity)
BigDouble value that is less than or equal to the
argument and is equal to a mathematical integer. Special cases:
- If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
- If the argument is NaN or an infinity, then the result is the same as the argument.
-
floor
-
floor
-
floor
-
ceil
- Returns:
- the smallest (closest to negative infinity)
BigDouble value that is greater than or equal to the
argument and is equal to a mathematical integer. Special cases:
- If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
- If the argument is NaN or an infinity, then the result is the same as the argument.
- If the argument value is less than zero but greater than -1.0, then the result is zero.
x.ceil()
is exactly the value ofx.neg().floor().neg()
.
-
ceil
-
ceil
-
ceil
-
trunc
Returns the smallest magnitude (closest to zero) BigDouble value that is less than or equal to the argument and is equal to a mathematical integer. Special cases:- If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
- If the argument is NaN or an infinity, then the result is the same as the argument.
- If the argument value is less than 1.0 but greater than -1.0, then the result is zero.
-
trunc
-
trunc
-
trunc
-
truncate
- See Also:
-
truncate
-
truncate
-
truncate
-
add
Adds two numbers together, returning the result as a BigDouble. Note that BigDouble operations are not in-place, and a new BigDouble instance is instantiated as the return value.- Parameters:
other
- a value, which may be a number, BigDouble, or valid String.- Returns:
- the sum of this BigDouble and the other value.
-
add
-
add
-
plus
- See Also:
-
plus
-
plus
-
sub
Subtracts the provided value from this BigDouble, returning the result as a BigDouble. Note that BigDouble operations are not in-place, and a new BigDouble instance is instantiated as the return value.- Parameters:
other
- a value to subtract, which may be a number, BigDouble, or valid String.- Returns:
- the difference of this BigDouble and the other value.
-
sub
-
sub
-
subtract
- See Also:
-
subtract
-
subtract
-
minus
- See Also:
-
minus
-
minus
-
mul
Multiply two numbers together, returning the result as a BigDouble. Note that BigDouble operations are not in-place, and a new BigDouble instance is instantiated as the return value.- Parameters:
other
- a value to multiply, which may be a number, BigDouble, or valid String.- Returns:
- the product of this BigDouble and the other value.
-
mul
-
mul
-
multiply
- See Also:
-
multiply
-
multiply
-
times
- See Also:
-
times
-
times
-
div
Divides this BigDouble by the provided value, returning the result as a BigDouble. Note that BigDouble operations are not in-place, and a new BigDouble instance is instantiated as the return value.Special cases:
- If the provided value is 0.0, the result will be NaN.
- Parameters:
other
- a value to subtract, which may be a number, BigDouble, or valid String.- Returns:
- the quotient of this BigDouble and the other value.
-
div
-
div
-
divide
- See Also:
-
divide
-
divide
-
divideBy
- See Also:
-
divideBy
- See Also:
-
divideBy
-
dividedBy
- See Also:
-
dividedBy
-
dividedBy
-
recip
Returns the reciprocal of this value.Special cases:
- If the provided value is 0.0, the result will be NaN.
- If the provided value is Infinite, the result will also be infinite.
- Returns:
- the sum of this BigDouble and the other value.
-
recip
-
recip
-
reciprocal
- See Also:
-
reciprocal
-
reciprocal
-
reciprocate
- See Also:
-
reciprocate
-
reciprocate
-
compareTo
- Specified by:
compareTo
in interfaceComparable<BigDouble>
-
cmp
-
hashCode
public int hashCode() -
equals
-
equals
-
equals
public boolean equals(double other) -
equals
-
eq
-
eq
public boolean eq(double other) -
eq
-
neq
-
neq
public boolean neq(double other) -
neq
-
notEquals
-
notEquals
public boolean notEquals(double other) -
notEquals
-
lt
-
lt
public boolean lt(double other) -
lt
-
lessThan
-
lessThan
public boolean lessThan(double other) -
lessThan
-
lte
-
lte
public boolean lte(double other) -
lte
-
lessThanOrEqualTo
-
lessThanOrEqualTo
public boolean lessThanOrEqualTo(double other) -
lessThanOrEqualTo
-
gt
-
gt
public boolean gt(double other) -
gt
-
greaterThan
-
greaterThan
public boolean greaterThan(double other) -
greaterThan
-
gte
-
gte
public boolean gte(double other) -
gte
-
greaterThanOrEqualTo
-
greaterThanOrEqualTo
public boolean greaterThanOrEqualTo(double other) -
greaterThanOrEqualTo
-
max
-
max
-
max
-
min
-
min
-
min
-
clamp
-
clampMin
-
clampMax
-
cmp_tolerance
-
compare_tolerance
-
eq_tolerance
-
equals_tolerance
-
neq_tolerance
-
notEquals_tolerance
-
lt_tolerance
-
lte_tolerance
-
gt_tolerance
-
gte_tolerance
-
log10
public double log10() -
log10
-
log10
public static double log10(double value) -
log10
-
absLog10
public double absLog10() -
absLog10
-
absLog10
public static double absLog10(double value) -
absLog10
-
pLog10
public double pLog10() -
pLog10
-
pLog10
public static double pLog10(double value) -
pLog10
-
log
public double log() -
logarithm
public double logarithm() -
logarithm
-
log
public double log(double base) -
logarithm
public double logarithm(double base) -
log2
public double log2() -
ln
public double ln() -
ln
-
ln
public static double ln(double value) -
ln
-
pow10
-
pow10
-
pow10
-
pow
-
pow
-
exp
-
exp
-
exp
-
exp
-
sqr
-
sqr
-
sqr
-
sqr
-
sqrt
-
sqrt
-
sqrt
-
sqrt
-
cube
-
cube
-
cube
-
cube
-
cbrt
-
cbrt
-
cbrt
-
cbrt
-
affordGeometricSeries
public static BigDouble affordGeometricSeries(BigDouble resourcesAvailable, BigDouble priceStart, BigDouble priceRatio, long currentOwned) If you're willing to spend 'resourcesAvailable' and want to buy something with exponentially increasing cost each purchase (start at priceStart, multiply by priceRatio, already own currentOwned), how much of it can you buy? Adapted from Trimps source code. -
affordGeometricSeries
-
sumGeometricSeries
public static BigDouble sumGeometricSeries(int numItems, BigDouble priceStart, BigDouble priceRatio, int currentOwned) How much resource would it cost to buy (numItems) items if you already have currentOwned, the initial price is priceStart and it multiplies by priceRatio each purchase? -
affordArithmeticSeries
public static BigDouble affordArithmeticSeries(BigDouble resourcesAvailable, BigDouble priceStart, BigDouble priceAdd, int currentOwned) If you're willing to spend 'resourcesAvailable' and want to buy something with additively increasing cost each purchase (start at priceStart, add by priceAdd, already own currentOwned), how much of it can you buy? -
sumArithmeticSeries
public static BigDouble sumArithmeticSeries(int numItems, BigDouble priceStart, BigDouble priceAdd, int currentOwned) How much resource would it cost to buy (numItems) items if you already have currentOwned, the initial price is priceStart and it adds priceAdd each purchase? Adapted from ... -
efficiencyOfPurchase
public static BigDouble efficiencyOfPurchase(BigDouble cost, BigDouble currentRpS, BigDouble deltaRpS) When comparing two purchases that cost (resource) and increase your resource/sec by (deltaRpS), the lowest efficiency score is the better one to purchase. From Frozen Cookies: ... -
randomDecimalForTesting
-
toDouble
public double toDouble() -
mantissaWithDecimalPlaces
public double mantissaWithDecimalPlaces(int places) -
toString
-
toExponential
-
toPrecision
-
sinh
-
sinh
-
sinh
-
sinh
-
cosh
-
cosh
-
cosh
-
cosh
-
tanh
-
tanh
-
tanh
-
tanh
-
asinh
public double asinh() -
asinh
-
asinh
public static double asinh(double value) -
asinh
-
acosh
public double acosh() -
acosh
-
acosh
public static double acosh(double value) -
acosh
-
atanh
public double atanh() -
atanh
-
atanh
public static double atanh(double value) -
atanh
-
ascensionPenalty
Joke function from Realm Grinder -
egg
Joke function from Cookie Clicker. It's 'egg' -
main
-