What is 1e308 of 1e308 of 1e308?

@Kiwasi
Thanks for the link. But I did not mean an example of a idle game. But an example of an idle where you have some score that grows exponentially, which would justify the need to encode numbers of the order of 1e900.

Do you really technically need to handle (doing arithmetic and such) numbers of that order?

Yes, they need to be able to be summed.

And Cookie Clicker (as I previously mentioned) is probably one of the most well known versions of the genre:
http://orteil.dashnet.org/cookieclicker/

In which you build grandmas, factories, and other stuff to do the clicking for you.

Yeah, the genre sounds insane and stupid. But it’s very popular.

1 Like

Many games, including Cookie Clicker has max values at (1.79e308), after reaching that number, the “numbers” become infinity. I don’t want that kind limitation on my game, so I want something that can handle it.

I don’t think you technically need to store such big numbers, you could do simple tricks instead. You could simply keep track of 10-exponent (or unit prefix) into a separate integer, like:
0:unit (1e0)
1:deca (1e1)
2:hecto (1e2)
3:kilo (1e3)
…

Then as you number increase, you just have to increment your unit prefix and divide your number by 10 for each increment. Using this trick with a uint, you number can go over 1e4294967295. Would that be enough?

1 Like

Yes, count magnitudes and work around it like that. Idle games of this sort typically don’t drop down before the reset, so losing a few fractions won’t hurt. One septaquintillion here, one septaquintillion there - it all adds up to REAL money eventually anyway.

You can increment magnitude in thousands (kilo, million etc.), and divide it by three to get the symbol from a table. But you should probably look at a way to incrementally build up new symbols as you get into the REALLY silly numbers, so that a lookup-table isn’t necessary. Or make a hybrid solution where you generate this table at the start. Also leave an alternative display option with exponents. You CAN go to infinity and beyond with a few sneaky tricks :slight_smile:

1 Like

Yes, that would work.

Since OP agreed already when they saw my demo code that does exactly that.

    /// <summary>
    /// Represents a value as sig * 10^exp
    /// Or basically, sig following by _exp zeros
    /// </summary>
    public struct LargeInt
    {
        private long _sig;
        private int _exp;

        public LargeInt(int value)
        {
            _sig = value;
            _exp = 0;
        }

        public LargeInt(long value)
        {
            _sig = value;
            _exp = 0;
        }

        public override string ToString()
        {
            if (_exp == 0)
                return _sig.ToString();
            else if (_exp > 0)
                return _sig.ToString() + new string('0', _exp);
            else
                return string.Empty; //do we want to support fractions???
        }

     
        public static implicit operator LargeInt(int value)
        {
            return new LargeInt(value);
        }

        public static implicit operator LargeInt(long value)
        {
            return new LargeInt(value);
        }

        public static LargeInt operator +(LargeInt a, LargeInt b)
        {
            if(a._exp < b._exp)
            {
                var c = b;
                b = a;
                a = c;
            }

            int dif = a._exp - b._exp;
            if (dif > 19) return a; //out of range

            long s = b._sig;
            while (dif > 0)
            {
                dif--;
                s /= 10;
            }
            a._sig += s;
            return a;
        }

        //implement other operators

    }