Comments and answers for "Big Numbers - How to convert (k, M, a )"
http://answers.unity.com/questions/1552975/big-numbers-how-to-convert-k-m-a.html
The latest comments and answers for the question "Big Numbers - How to convert (k, M, a )"Comment by Eno-Khaon on Eno-Khaon's comment
http://answers.unity.com/comments/1555902/view.html
Ahh, right. That makes sense to want to truncate instead. In that case, rather than <i>Mathf.Round()</i>, you can use <i>Mathf.Floor()</i>. That will automatically reduce the value down rather than rounding up if the value is high enough.Sun, 23 Sep 2018 10:25:10 GMTEno-KhaonComment by Sagnog01 on Sagnog01's comment
http://answers.unity.com/comments/1555850/view.html
Wow!
This is to theoretical for me ahah!
I think I understood just an half of itSun, 23 Sep 2018 02:05:22 GMTSagnog01Comment by Sagnog01 on Sagnog01's comment
http://answers.unity.com/comments/1555849/view.html
Hey :)
I tried that and I get some strange results.
DisplayConverter.RoundToNearest(2.209f, 2) gives me 2.21f instead of 2.20.
Not sure if this function works the way I needSun, 23 Sep 2018 02:04:47 GMTSagnog01Comment by Eno-Khaon on Eno-Khaon's comment
http://answers.unity.com/comments/1555390/view.html
Due to the general nature of the "Idle Click Game" genre, much of the point of them is purely to reach ridiculously huge numbers for that sense of endless "progress" throughout them.
<br> <br>
as an example of how over-the-top the number systems in this genre can be, <b>[Clicker Heroes][1]</b> reaches money values exceeding 1.0*10<sup>50000</sup>. Despite that, it starts off with single-digit numbers.
<br> <br>
It's definitely true that smaller values (relatively speaking) will become insignificant after just a few factors of ten. With that in mind, along with consideration for the extraordinary numbers these games intentionally reach toward, my aim is to provide a means of reaching excessively large numbers, providing feedback on values while they're still meaningful (within a few factors of ten), and also trying to keep the math library simpler and cheaper by not relying on a 128-bit+ math library.
<br> <br>
While your points are all perfectly valid (and normal, really), this genre of game has a knack for ignoring all typical, sensible logic when it comes to numbers. Once you reach those high values, nothing will visibly matter for millennia or more unless they're "close enough" already.
[1]: https://www.clickerheroes.com/Fri, 21 Sep 2018 09:49:40 GMTEno-KhaonComment by Bunny83 on Bunny83's answer
http://answers.unity.com/comments/1555380/view.html
Sorry to burst your bubble on this one, but your suggested solution is pretty pointless ^^. A normal float already has a range of 10^38 which is already huge. Extending just the exponent manually just increases the overall range but you stay at the same precision which is pretty bad the higher the values get. [See this table][1]. Even you can represent such huge numbers you can't really do any useful math with them since the usable range is relative to the binary point. If the number is about 100 million the smallest change you can apply to the number is about "4". This relative distance scales linearly. So when you have 100 billion the smallest representable change would be around "4000".
<br>
Just using double instead of float will boost the actual significant digits but also the exponent range. double has a range of about 10^300.
<br>
If all the number scale linearly with your max amount it would be just a matter of using different suffix letters while using the same down scaled number. If you actually need to work with those numbers it would be more practical to split the number into a float and a "long" part. Say you allow the float a range of +-1000 to keep the precision. If the float gets larger than 1000 you would carry those 1000 as 1 into the long value. The long type goes up to 9,223,372,036,854,775,807. Since value each represents 1000 you get an even larger range.
<br>
Of course it's not as large as any floating point solution but it can at least work with small changes like "+1". Again the single precision float looses the "+1" ability around 32 million. If you want to be able to *smoothly* increase a value by 1 every second you would need the ability to add 1/60 every frame (when running at a framerate of 60fps). So that would be "0.01666". Using just a float (with or without extended exponent) you can't go higher than about 100k in total
[1]: https://answers.unity.com/questions/698516/hypothetical-what-happens-if-timetime-overflows.html?childToView=1415865#answer-1415865Fri, 21 Sep 2018 09:12:38 GMTBunny83Comment by Eno-Khaon on Eno-Khaon's comment
http://answers.unity.com/comments/1555363/view.html
One way you can approach that is a safety net by truncating.
<br> <br>
You could use something along the lines of:
float displayedValue = Mathf.Floor(floatValue * 100f) * 0.01f;
<br>
That would accommodate single digit values with decimal only, in that simple of a form, but rounding with the number temporarily inflated is the typical basis for rounding to the nearest whichever-digit.
<br> <br>
For a slightly more computationally expensive variation, but more versatile, you can use a function to truncate a value down to something other than a basic whole number:
// Truncates toRound to the next digit-count (factor of ten)
float FloorToNearest(float toRound, int digits)
{
float multiplier = Mathf.Pow(10f, digits);
return Mathf.Floor(toRound * multiplier) / multiplier;
}
The digits would be, for example:
digits | truncates to:
-3 | 1000
-2 | 100
-1 | 10
0 | 1
1 | 0.1
2 | 0.01
3 | 0.001
A value of <i>0</i> would result in a normal <i>Floor()</i> function. In the case of your example, a value of <i>2</i> would round 2.001 to the nearest 0.01, resulting in <i>2.00</i>.
<br> <br>
Edit: Changed from rounding to truncating.Fri, 21 Sep 2018 07:51:17 GMTEno-KhaonComment by Sagnog01 on Sagnog01's comment
http://answers.unity.com/comments/1555291/view.html
Hey again man!
Last question: I swear ahah!
I've made a script where I can get always 3 number on the screen. (1.01$$anonymous$$, 10.2$$anonymous$$ or 200$$anonymous$$).
Also I've made a simple function that whenever the number is 2.00$$anonymous$$ it only shows 2$$anonymous$$.
----------
The problem is that if the number is: 2.001, my script puts 2.00 instead of 2.
How can I solve this?
Thank you so much againThu, 20 Sep 2018 23:39:41 GMTSagnog01Comment by Eno-Khaon on Eno-Khaon's comment
http://answers.unity.com/comments/1554008/view.html
Yeah, your edit pretty much sums that up. What you keep track of and what you display can be separate from each other. When using float values, for instance:
floatValue.ToString("f3")
... will give you a string with 3 decimal places. More options for string formatting are documented well <b>[here][1]</b>.
[1]: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-stringsMon, 17 Sep 2018 09:36:43 GMTEno-KhaonComment by Sagnog01 on Sagnog01's comment
http://answers.unity.com/comments/1553877/view.html
Thanks man :D
I'm implementing the functions right now.
How can I keep a float with only 3 decimal places.
1,024 instead of 1,024523
I know how to write in the console with just 3 decimal places, but I want to save the value as 1,024.
Or maybe I can write a function where :
if (decimalPlaces == 4)
ignore(lastOne)
How do I accomplish this?
Edit:
Or maybe I'm overthinking and I don't need to worry about it. Just need to show the value with 3 decimal places.
Thank you very muchSun, 16 Sep 2018 22:43:35 GMTSagnog01Comment by Eno-Khaon on Eno-Khaon's comment
http://answers.unity.com/comments/1553336/view.html
Happy to help. Yeah, it'll involve a bit of script-writing to make it all fit together nicely, but it shouldn't be <b>too</b> bad.
<br> <br>
The key point to keep in mind with this approach will be that comparing exponents will be the ever-important first step. You can't rely on converting the values first, since the true, complete values (even as differences between them) may easily exceed the accuracy available to the float values themselves.
<br> <br>
Furthermore, you can also give yourself string output variations in the script for when you want to display it shorthand (1e15) or verbose (1 quadrillion). If you wish to pursue that route, then a little research on the naming patterns should let you assemble value names based on the exponent value (or, rather, its multiple of 3).Fri, 14 Sep 2018 22:49:32 GMTEno-KhaonComment by Sagnog01 on Sagnog01's answer
http://answers.unity.com/comments/1553311/view.html
Thank you so much for your detailed answer !
Basically I save 2 values (float and int) and use them to calculate the values of stuff, right ?
Using this method I think it's pretty easy to write the number in the screen.
If the money is 3.4e6 , I just need to check the exponential (6) . If it's 6, then the player has 3.4 Million Coins.
You are awesome. Thank you so much.
Now I "just" have to write the functions :)Fri, 14 Sep 2018 21:50:59 GMTSagnog01Answer by Eno-Khaon
http://answers.unity.com/answers/1553010/view.html
If you're especially worried about perfect accuracy, you may want to dig around the internet a bit to find a solution that's suitable for your needs. The first few examples I found as far as related links go include <b>[here][1]</b> and <b>[here][2]</b>.
<br> <br>
If 100% perfect accuracy isn't important (and, looking at this realistically, it might not be when you consider that 150,000 out of 500 duoquinquagintillion is genuinely insignificant), you could try taking a different approach to this.
<br> <br>
For example, you might consider comprising your values of a pair of numbers. The first would be the general value, where the second is the exponent of 10 to apply to it. If you had a base value of 3.424126 and an exponent of 10, the resulting number would be 34,241,260,000. It's fundamentally like what floating point numbers do internally, but you'd just assemble the number yourself (seeing how the first number would even be a float in the first place).
<br> <br>
To compare values, you'd multiply the difference in exponents with the base value. For example,
<br>
3.4<sup>e10</sup> - 2.2<sup>e9</sup> = 3.18<sup>e10</sup>
<br>
3.4 - (2.2 * 10<sup>9-10</sup>) = 3.18
<br>
3.4 - (2.2 * 10<sup>-1</sup>) =3.18
<br>
3.4 - 0.22 = 3.18
<br> <br>
If the difference between values is greater than a number of significant digits specified (for instance, Unity's floating point has 7 digits of accuracy), then the difference can potentially be considered large enough to ignore the math altogether.
<br>
3.4<sup>e10</sup> - 5<sup>e2</sup>
<br>
2 - 10 = -8
<br>
|-8| > 7 (accuracy)
<br>
As far as it matters...
<br>
3.4<sup>e10</sup> - 5<sup>e2</sup> = 3.4<sup>e10</sup>
<br> <br>
If you put together a general value-type script to utilize number pairs in that manner, you can also make quick assumptions for shortcuts. For instance, if the exponent for a "purchase" is greater than your current "money" exponent, you already know you can't afford it.
<br> <br>
Edit: For additional reading, <b>[consider this list of large number naming conventions][3]</b>.
[1]: https://forum.unity.com/threads/c-solution-for-big-numbers.334590/
[2]: https://gamedev.stackexchange.com/questions/114911/how-do-idle-games-handle-such-large-numbers
[3]: https://www.quora.com/What-comes-after-a-million-billion-trillionFri, 14 Sep 2018 03:55:22 GMTEno-Khaon