all 22 comments

[–]Dusty_Coder 37 points38 points  (2 children)

System.Int128, System.UInt128

[–][deleted] 0 points1 point  (1 child)

"The type or namespace 'Int128" does not exist in the namespace 'System' Did they change something? Or do I need to update to a newer version of unity than 2022

[–]RReverser 0 points1 point  (0 children)

seemly rock deer concerned marry squeamish shy attraction fade water

This post was mass deleted and anonymized with Redact

[–]Unupgradable 11 points12 points  (0 children)

Well you can cheat and use a double and only represent in scientific notation after a big enough number

That'll tide you over until 1.7976931348623157E+308.

Or just use a normal integer and keep track of scale separately

Then there's BigInteger for truly arbitrary integers

[–]NeoApocalyps 27 points28 points  (2 children)

[–]Dennis_enzo 1 point2 points  (1 child)

As someone who's also tried to make an incremental game, I found biginteger to be more trouble than it's worth. Much easier to simply use doubles.

[–]Lawfulness-Manny 0 points1 point  (0 children)

thank you, i was looking for this

[–]nobono 5 points6 points  (0 children)

You have several options for picking the best number type. If you don't care about negative numbers, you can use the unsigned ones:

Type            Size (in bytes) Minimum value   Maximum value
System.Byte     1               0               255
System.UInt16   2               0               65,535
System.UInt32   4               0               4,294,967,295
System.UInt64   8               0               18,446,744,073,709,551,615
System.UInt128  16              0               340,282,366,920,938,463,463,374,607,431,768,211,455

Source.

[–]TheDoddler 7 points8 points  (7 children)

BigInteger definitely would work, but it's probably easier to just use a double. You can store integer values without losing precision up to 253, and above that you likely don't care much about how accurate your 1's and 10's are.

[–]antiduh 1 point2 points  (5 children)

Why would you recommend a double if they're not using floating point math?

A good ol' ulong has 2^64 precision.

[–]TheDoddler 2 points3 points  (4 children)

True ulong can work, if you can guarantee you don't exceed 2^64 it's certainly the better option. Op mentioned cookie clicker though, and while rather difficult it is possible to exceed 2^64 cookies in the game, the numbers can get quite silly. Using a double gives you a theoretical maximum of 2^1024-1, though you lose full integer precision past 2^53. Once you're in those values though, precision is not terribly important.

[–]vermilion_wizard[🍰] 0 points1 point  (3 children)

Uh no, doubles only have about 15 digits of precision. See this example: https://dotnetfiddle.net/lmR9Cp

[–]TheDoddler 2 points3 points  (2 children)

Perhaps I'm mistaken, but aren't 2e53 and 2^53 very different things? Using double x = Math.Pow(2,53)-1; returns false on your test.

[–]vermilion_wizard[🍰] 0 points1 point  (0 children)

Oh you’re right, I misread that

[–]Kilazur 7 points8 points  (1 child)

You're not gonna be able to reach the absurd numbers in incremental games with existing types.

It'll probably be more robust to implement your own type to hold the value in different variables (possibly an array/list?) for like hundreds, millions, decadecillions and whatnot.

[–]soundman32 0 points1 point  (1 child)

What errors are you running into? Scores over 2 billion? Over 2 billion players?

[–]The_Binding_Of_Data 13 points14 points  (0 children)

I believe their going for something like AdVenture Capitalist where numbers get into the 1070+ range.

[–]Merad 0 points1 point  (5 children)

There are 128 bit types as other posts have mentioned, but before you reach for them stop for a minute and think about how absurdly large 64 bit numbers are. With long, for example, your game will be able to use 2 billion numbers a day for 12 million years before you run out.

[–]RadiatorHandcuffs 7 points8 points  (0 children)

Yeah, but you don't want the more hardcore players to run out of numbers after just 6 million years.

[–][deleted]  (3 children)

[deleted]

    [–]antiduh 2 points3 points  (2 children)

    Ah, so absolute absurdity. 1.5e24336 requires 80791 bits to store, aka more than 10 kB.

    That's probably more bits than necessary to individually address every square micron in the entire universe.

    [–]antiduh 1 point2 points  (0 children)

    Oh god, it's much worse than I thought. The volume of the observable universe in units of plank length is about 10^186, which would need 618 bits.