When making games with really large numbers, do formatted numbers then still count as their initial value digit-wise?
For instance:
10.000 = 10k.
Does 10k count as 2 or 5 digits?
If so is there no way to convert them, so that 1m would simply count as 1 digit (or 2 if the “M” counts)?
Are you asking about character space?
If that was the case, what you see is what’s counted You’d format the number to display it.
If you want to show 10,000 as 10k it’s 3 characters to show, right?
I think I phrased my question badly
It’s my understanding that an int, long, float, double and so on, can only contain a specific amount of digits (with or without decimals, depending on the type).
I may have gotten it all wrong, but I always thought that an integer for instance would be able to show number between -2,147,483,648 and 2,147,483,647.
Would I be able to show the number 1.000.000.000.000 if formatted as 1T or would it still count as a trillion and be too big??
I see, I see. Okay… The value it can store is based on its memory size. Yes there are limits. Try a quick google search for the exact limits in c# if you really want to know. For a trillion (if that’s a limit), you’d want to use ‘long’.
And to sort of touch on your first message, you cannot even declare a variable with ‘k’.
int num = 10k; // is not valid code
(of course you can write it out to the game screen as “10k” but that’s different).
It’s actually not really for my game… I was playing a game - one of those clicker games that reach VERY high numbers.
I asked someone why the late-game was lacking content, to which they responded that the devs had a problem with the numbers getting too big, for the doubles they’re using…
Their numbers appear as formatted, so I assumed that would never be a problem, but evidently it is, which made me wonder about the question asked in this thread
A fixed point system has a specific range of numbers it can show, and can show all integers in that range. These types include:
byte, int, long
A floating point system has a significant value range that it can show, and will move the decimal point (float the decimal point) allowing for a much larger range. There is no guarantee that all integers in that range are possible to be shown, but that any number with a the number of sig values will fit in that range. These types include:
float, double, decimal
Having about 7 sig values, 16 sig values, and 28 sig values respectively.
Note, I say ‘integer’, because theoretically there are an infinite number of ‘numbers’ between any 2 integers. But this isn’t to mean that fixed point systems can only represent integers… you can find fixed point systems that support a fixed width of fractional values.
Anyways… the system you describe (OP), a floating point system like a float (obvsly named) or double-float would suffice. It’s storing mechanism would take a number like 1.000.000.000 and store it as the binary equivalent of 1*10^9.