Closed Drillur closed 1 year ago
That's cool! Love to see people using and expanding the code. I have no idea what logarithmic notation is, and why it's useful - can you explain how and why you use it in your game?
Log notation is like scientific notation, just a way to display a huge number, but it is a little different!
First, it displays the exponent first. For 1 million, it would read e6 which is 1e6 in scientific.
Next, it still shows the mantissa, but as a decimal after the exponent. For 5 million, which is 5e6 in scientific, it would read e6.7 in log notation. It's .7, instead of .5, because the mantissa is calculated in log base 10.
In effect, when an in-game resource like gold is going up incrementally, in log notation it appears to go up quickly and then slows down at the end of the exponent. This keeps things very relative. At the beginning of the next power (e7), the gold count continues to appear to be slowing down in speed, even if though it is increasing incrementally.
To be clear, I don't have a full understanding of log in the real world of math, but I have been using log notation while I test it, and I have enjoyed seeing the exponent in the forefront of the number.
I added this because I have added options for notation that the players may choose, and logarithmic notation is the up-and-coming choice for seasoned idle game players.
-
In the code I've posted above, it will at most display 3 decimals after the exponent, with as little as no decimals (like e10).
In the format_exponent function, that is just in case the exponent ever goes above 1000, which is unlikely in most games, but I thought I'd add it just in case. (In the case of 500k exponent, it would return "500,000" .)
I have added this now. Adjusted your code to support some of the other features in the class. Better late than never right ;-)
Function is called toLogarithmic()
Hey, I don't know how to make a code submission to your project, so I'm just writing it here.
I wrote logarithmic notation for your Big class. You don't have to implement it, just thought I'd share what I added for my game.
Some examples of going from scientific to log notation:
1e10 = e10 2e10 = e10.3 6.5e10 = e10.81 9e10 = e10.95
The code is below. It only works with positive numbers.
-
Thanks for like the 3rd time for making BigNumberClass!