Patashu / break_eternity.js

A Javascript numerical library to represent numbers as large as 10^^1e308 and as small as 10^-10^^1e308. Sequel to break_infinity.js, designed for incremental games.
MIT License
120 stars 43 forks source link

Some constants don't match break_infinity.js documentation #171

Closed JamesCarlyleClarke closed 1 month ago

JamesCarlyleClarke commented 1 month ago

Some of the constants don't match the break_infinity.js documentation; I'm not sure about the methods. I produced an automated list, I have not manually checked this, but it might be a useful start for any additional documentation.

Here are the constants:

dZero: Represents the number zero. (FC_NN(0, 0, 0)).
dOne: Represents the number one. (FC_NN(1, 0, 1)).
dNegOne: Represents the number negative one. (FC_NN(-1, 0, 1)).
dTwo: Represents the number two. (FC_NN(1, 0, 2)).
dTen: Represents the number ten. (FC_NN(1, 0, 10)).
dNaN: Represents a NaN (Not a Number) value. (FC_NN(Number.NaN, Number.NaN, Number.NaN)).
dInf: Represents positive infinity. (FC_NN(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)).
dNegInf: Represents negative infinity. (FC_NN(-1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)).
dNumberMax: Represents the maximum value a JavaScript number can have. (FC(1, 0, Number.MAX_VALUE)).
dNumberMin: Represents the minimum value a JavaScript number can have. (FC(1, 0, Number.MIN_VALUE)).

Here is the list of functions, with their parameters and brief explanations:

acos(): Computes the arccosine of a Decimal. Returns: Decimal
atan(): Computes the arctangent of a Decimal. Returns: Decimal
sinh(): Computes the hyperbolic sine of a Decimal. Returns: Decimal
cosh(): Computes the hyperbolic cosine of a Decimal. Returns: Decimal
tanh(): Computes the hyperbolic tangent of a Decimal. Returns: Decimal
asinh(): Computes the hyperbolic arcsine of a Decimal. Returns: Decimal
acosh(): Computes the hyperbolic arccosine of a Decimal. Returns: Decimal
atanh(): Computes the hyperbolic arctangent of a Decimal. Returns: Decimal
ascensionPenalty(): Applies a penalty based on ascensions, joke function from Realm Grinder. Returns: Decimal
sin(): Computes the sine of a Decimal. Returns: Decimal
cos(): Computes the cosine of a Decimal. Returns: Decimal
tan(): Computes the tangent of a Decimal. Returns: Decimal
asin(): Computes the arcsine of a Decimal. Returns: Decimal
log2(): Computes the base-2 logarithm of a Decimal. Returns: Decimal
ln(): Computes the natural logarithm of a Decimal. Returns: Decimal
logarithm(base: number): Computes the logarithm of a Decimal with the given base. Returns: Decimal
pow(value: number | Decimal): Raises a Decimal to the power of the given value. Returns: Decimal
pow10(): Raises 10 to the power of a Decimal. Returns: Decimal
root(value: number | Decimal): Computes the root of a Decimal. Returns: Decimal
factorial(): Computes the factorial of a Decimal. Returns: Decimal
gamma(): Computes the gamma function of a Decimal. Returns: Decimal
lngamma(): Computes the natural logarithm of the gamma function of a Decimal. Returns: Decimal
exp(): Computes the exponential function of a Decimal. Returns: Decimal
sqr(): Squares a Decimal. Returns: Decimal
sqrt(): Computes the square root of a Decimal. Returns: Decimal
cube(): Cubes a Decimal. Returns: Decimal
negated(): Negates a Decimal. Returns: Decimal
sgn(): Returns the sign of a Decimal. Returns: number
round(): Rounds a Decimal to the nearest integer. Returns: Decimal
floor(): Rounds a Decimal down to the nearest integer. Returns: Decimal
ceil(): Rounds a Decimal up to the nearest integer. Returns: Decimal
trunc(): Truncates a Decimal to its integer part. Returns: Decimal
multiply(value: number | Decimal): Multiplies two Decimals. Returns: Decimal
times(value: number | Decimal): Multiplies two Decimals. Returns: Decimal
div(value: number | Decimal): Divides one Decimal by another. Returns: Decimal
divide(value: number | Decimal): Divides one Decimal by another. Returns: Decimal
divideBy(value: number | Decimal): Divides one Decimal by another. Returns: Decimal
dividedBy(value: number | Decimal): Divides one Decimal by another. Returns: Decimal
recip(): Computes the reciprocal of a Decimal. Returns: Decimal
reciprocal(): Computes the reciprocal of a Decimal. Returns: Decimal
reciprocate(): Computes the reciprocal of a Decimal. Returns: Decimal
mod(value: number | Decimal): Computes the remainder of the division of one Decimal by another. Returns: Decimal
modulo(value: number | Decimal): Computes the remainder of the division of one Decimal by another. Returns: Decimal
neg(value: number | Decimal): Negates a Decimal. Returns: Decimal
negate(value: number | Decimal): Negates a Decimal. Returns: Decimal
negated(value: number | Decimal): Negates a Decimal. Returns: Decimal
sign(value: number | Decimal): Returns the sign of a Decimal. Returns: number
sgn(value: number | Decimal): Returns the sign of a Decimal. Returns: number
round(value: number | Decimal): Rounds a Decimal to the nearest integer. Returns: Decimal
floor(value: number | Decimal): Rounds a Decimal down to the nearest integer. Returns: Decimal
ceil(value: number | Decimal): Rounds a Decimal up to the nearest integer. Returns: Decimal
trunc(value: number | Decimal): Truncates a Decimal to its integer part. Returns: Decimal
add(value: number | Decimal): Adds two Decimals. Returns: Decimal
plus(value: number | Decimal): Adds two Decimals. Returns: Decimal
sub(value: number | Decimal): Subtracts one Decimal from another. Returns: Decimal
subtract(value: number | Decimal): Subtracts one Decimal from another. Returns: Decimal
minus(value: number | Decimal): Subtracts one Decimal from another. Returns: Decimal
mul(value: number | Decimal): Multiplies two Decimals. Returns: Decimal
multiply(value: number | Decimal): Multiplies two Decimals. Returns: Decimal
times(value: number | Decimal): Multiplies two Decimals. Returns: Decimal
affordGeometricSeries(resourcesAvailable: Decimal, priceStart: Decimal, priceRatio: Decimal, currentOwned: number): Determines how much of an item you can buy with exponentially increasing cost. Returns: number
sumGeometricSeries(numItems: number, priceStart: Decimal, priceRatio: Decimal, currentOwned: number): Calculates the total cost of buying a number of items with exponentially increasing cost. Returns: Decimal
affordArithmeticSeries(resourcesAvailable: Decimal, priceStart: Decimal, priceAdd: Decimal, currentOwned: number): Determines how much of an item you can buy with additively increasing cost. Returns: number
sumArithmeticSeries(numItems: number, priceStart: Decimal, priceAdd: Decimal, currentOwned: number): Calculates the total cost of buying a number of items with additively increasing cost. Returns: Decimal
efficiencyOfPurchase(cost: Decimal, currentRpS: Decimal, deltaRpS: Decimal): Calculates the efficiency of a purchase based on resource cost and rate of resource increase. Returns: Decimal
MathCookie17 commented 1 month ago

For the methods, I wrote the documentation in a way that I think is more informative about the functions than the documentation you gave here. Fair point about the constants, though - I'll add documentation for those.

...I feel like I missed the point of what you're saying. Did you just mean "the documentation isn't worded the same", or were you trying to say something else?

JamesCarlyleClarke commented 1 month ago

Well, seems like I missed you updating the ReadMe to mention index.d.ts so my point is now partially lost, sorry! And by the way, if my past point or coming comments sounds like criticism then sorry, it really is not meant that way, it's a great library.

Still: 1) From the readme, [break_eternity.js] 'has the same interface, so it can be used as a drop-in replacement for break_infinity.js and decimal.js'. But a) the constants aren't the same, so it's not going to work as a 'drop-in', and b), I was using https://patashu.github.io/break_infinity.js/classes/default.html as documentation since it's got the same interface and is a drop-in replacement, so the constants didn't match there either.

2) 'A list of functions is provided earlier in this readme' but unless I'm being really stupid, I couldn't see one. And again, I had not noticed the new index.d.ts.

So apropos point 2 I thought perhaps that list could be provided for the readme, which is why I gave the list. I figured either it could be used in some simple list form, or as a basis for transferring the break_infinity.js docs. As it turns out, you have done something with index.d.ts so it's not so important, though maybe a simpler 'readme' form would be good in addition to the index?

Hope that helps.

MathCookie17 commented 1 month ago

v2.1.0 has added documentation for the constants.

  1. I'm not familiar with break_infinity, only break_eternity, so I guess you'll have to ask Patashu what "drop-in replacement" is supposed to mean here.
  2. The list of functions is the paragraph that begins with "Functions you can call include".

I'm still not sure if I actually covered your whole issue, so I'm not going to close it myself. Feel free to close the issue if the documentation for the constants is sufficient for what you were looking for.

JamesCarlyleClarke commented 1 month ago

Yeah, I took it to mean 'like-for-like' replacement where the methods, constants etc. match except in the few cases specified as not matching.

Anyway, there's documentation, I'm a happy bunny (and sorry for missing the update before I posted). Calling it closed, have a great one!

MathCookie17 commented 1 month ago

Anyway, there's documentation, I'm a happy bunny (and sorry for missing the update before I posted). Calling it closed, have a great one!

You didn't "miss the update before you posted", I just released the update an hour ago.

JamesCarlyleClarke commented 1 month ago

No, I meant not seeing the change to the ReadMe where you added a reference to index.d.ts, thus giving info on where we could find the methods, before I posted the original issue. I read it a few months back, when it just mentioned the ReadMe and not index.d.ts, and I never spotted the change.