Posted January 12, 2026 by SecretCoder123
Ok so what I am making is known as an idle game. Thing about idle games, they are about triggering dopamine through extremely large numbers. Thing about extremely large numbers, they don't fit in the integer limit (2^64) and they don't fit on my labels.
The solution: Scientific notation!!
Though I couldn't get it to work at first, Godot has a built-in scientific notation for it's floats. This will let me store numbers up to ~10^300! All you have to do it is define it in your float, e.g. var float: float = 1.0e10
This solved my problem one. The solution was simple but boy was I struggling! I just didn't understand why even when my variables were declared as floats, I was still getting integer limit errors.
Second problem: my labels are too small. Scientific notation strikes again!
I have a singleton called GameManager that I use for global variables. In it I built a function called scientifically_notate().
Now don't laugh please- this was my first time ever making a function that was intended to return a variable. This was a milestone, and it came just by thinking "boy, would it be convenient if my function could return a value. Wait, didn't I see someone DO it on a tutorial once?"
Anyway I had to dust off my math skills and put on my thinking cap, and came out with this masterpiece:
func scientifically_notate(value: float, precision: float) -> String:
#don't use scientific notation if the number is low
if value <= 100000:
return(str(int(value)))
else:
#scientific notation- mantisa is the multiplier, exponent is the exponent. This is handwritten code and it was way harder than I expected
var exponent: int = 0
#sets the exponent to log base 10 of money
exponent = floor((log(value)/log(10)))
var mantissa = 0
#divides money by the computed value of the exponent and sets mantissa to it
mantissa = value / pow(float(10e0), exponent)
#limits the mantissa
mantissa = snapped(mantissa, precision)
return(str(mantissa) + "e" + str(exponent))
Pretty good right? I am on track to hopefully be able to upload the first beta by this summer. Again, I will add it after I finish upgrades and save states, and I am already almost done with upgrades! Thanks for your time in reading this!