What is 1e308 of 1e308 of 1e308?

Since 1.7e308 is the Double.MaxValue.
I created a new variable that chains together multiple doubles.

public struct doubleChain {
        double first; // 1 = 1
        double second; //1 = 1e308 of first
        double third; //1 = 1e308 of second
}

So now my question is what the doubleChain.MaxValue?
My calculation brings me to 1.80e1024 as my MaxValue.

If anyone could help me answer this question, I’ll be grateful.

If anyone know a better way to code values greater than 1e308 please share.
In theory, I would like a max value of 1e10000 or even greater.

I’m not sure what doubleChain.MaxValue is because it’s not defined as far as I can tell.

Some Googling eventually brought me to the Rational Structure.

It stores everything as fractions, and the docs say something about being a preview, but you should be able to store a number to whatever magnitude or precision you want.

If you only are dealing with integers, then there is the BigInteger struct.

I’m writing a idle game.

It is ‘defined’. In the comments, it’s said,
1 doubleChain.third = 1e308 doubleChain.second
1 doubleChain.second = 1e308 doubleChain.first.

So if I have doubleChain.third = 1e308, what is my actual value?

Your wording is weird…

1e308 of first?

You’re saying you have “x of y”? That is a weird way of saying that…

OK, so having 5 of 3 is 15, it’s a multiple of them. So your max value would be 1.7e308 * 1.7e308 * 1.7e308.

Or 1.7e308^3.

Which would be about 4.913e924… though technically double.MaxValue is 1.7976931348623157e308, so really you have:
5.809605995369956048902737421321 e924

But, this sounds like a really horrible way to store your numbers. When you consider the way a ‘double’ stores its value.

The double is already a strangely formatted value, with its sign, exponent, and mantissa. I honestly don’t even know how your weird number here is going to perform arithmetic…

Furthermore, you’re going to have intermittent ranges. The double only has 53 significant binary values (or about 16 or 17 significant decimal values). But in this structure you’re going to have 3 groupings of ~16 sig values, with huge gaps (upwords of 291 in decimal) of zeroes in between.

I mean hell, if you’re going to need to define arithmetic of this bizarro number format. At least do it with a number format that is easier to describe.

  1. use a BigInt library (like previously suggested)
  2. use a format similar to double, like the quad:
    Quadruple-precision floating-point format - Wikipedia

This badboy gives you 113 sig binary digits (34 decimal), and a max value of 1.1897e4932.

That’s well above your measily e924, and is packed into 128bits, instead of your 192.

Heck, the Octuple which is only 256 bits, to your 192, has a sig value range of 237bits (71 decimal digits), and goes all the way up to 1.6113e78913.

And the arithmetic for these formats is already defined, you’d be able to look it up pretty easily.

4 Likes

I’m making a idle game, so precision isn’t really necessary. Additionally, BigInteger computing becomes really slow(1-2 seconds) after 1e10000. I want/need it to compute values within 1 frame at 30-60 FPS.
When values become 1e10000, it doesn’t really matter if the value is 1e9000 off. Cause 1e10000 - 1e9000 = 1e10000. I am not displaying all the digits but only “0.00e0”.

Still not an argument for your weird numeric type.

So BigInt is slow to perform arithmetic… what do you think this will be?

Lets just consider getting the string representation of it, that alone will be chaos.

HECK, if you want fast arithmetic, and large range, I’d go with integers, and store a large decimal. As a number increases you don’t care about the smaller range anyway, like you said. So, instead:

    /// <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

    }

This will be decently fast, faster even than your double implementation.

The arithmetic is simple compared to your double imp.

The sig value range is 63-bits (19 digits), more than your double imp.

The max value range is upward of 9.223 e2,147,483,647, larger than your double imp.

… your double imp doesn’t even REACH that number.

Anyways,

Whatever route you go with, you got your answer.

You now know what your max value is.

And if you determine that this is simpler arithmetic than that double imp, you’ll have it as an example to implement. (note my code is untested and serves as an example)

You’re absolutely right.
I could definitely implement this into my project.

Thanks for the help.

Just curious.
Why would you need such large numbers for?

It’s a clicker, some people like to have their clickers go up to stupidly high numbers.

I guess OP wants to surpass the 1e308 cookies that ‘double’ would limit them to.

What lordofduct said.

If you expect your users to reach this amount of clicks, considering the time that would take, then you would need to design a server and host it in a parallel universe that would resist the next big bangs.

[quote=“ericbegue, post:13, topic: 629309, username:ericbegue”]
If you expect your users to reach this amount of clicks, considering the time that would take, then you would need to design a server and host it in a parallel universe that would resist the next big bangs.
[/quote]It’s not the amount of clicks, it’s the gold and experience rewards. Clicker games raise the gold/xp reward exponentially, and continue to raise it exponentially until we hit absurd numbers.

Checkout the table on the right of Clicker Heroes. You can see how crazy high the gold amounts get.

2662736--187773--upload_2016-6-3_9-21-6.jpg

It’s an entire genre of games. It’s a type of idle game.

The point is usually “for every click you get points, with said points you can build/purchase/manufacture some in game entity that will perform clicks for you”.

One of the most famous ones is “Cookie Clicker”, where you’re making cookies. But you can build grammas, and factories and other nonsense to make your cookies for you. It’s something where when you get it tuned it just makes your cookies for you…

It’s a WEIRD genre.

I never understood them until I played this one… some dungeon crawler clicker.
http://minmaxia.com/c2/

Clickpocalypse 2 was its name.

We actually wrote a script to play the game for us. Because you really only had to click to cast spells and level up your character. But if you clicked when you were out of spells, it wasn’t a big deal. So I just wrote a script that clicked everything constantly on an interval and let it sit.

I’d come back a day or so later with a fully leveled up party, and I’d collect my bonuses, and repeat.

Stupid genre, I swear.

Yes. But surprisingly addictive and popular. Kongregate is almost useless for finding games on now because all of the top lists are dominated by idle games.

The games are also pretty easy to develop too. No graphics. Just numbers. The only real programming challenge is the potential to overflow numbers.

Still. This type of game does not justify the need for such large numbers.

Let’s say, the player is extremely fast and can click 60 times per second (overly exaggerated).
That would be 3600 clicks per minute, 216 000 per hour, 5 184 000 per day, 1 893 456 000 per year (~1.8e9).

Now let’s take an unsigned long int, which can count up to:
18 446 744 073 709 551 615
(according to this doc).

At this clicking rate that number would be overflown in:
18446744073709551615/(60606024365.25)
Which is ~9.7 billion years!

For comparaison, the age of the universe is estimated at 13.77 billion years (according to this).

The OP want a number of the order of 1e3081e3081e308 = 1e924.
At the same click rate, in would be overflown in:
1e924/1e10 = 1e914 years, that’s is 1e905 billion years… It’s not even expressible…

Except the games are built on an exponential curve. They very much rely on a Skinner box model. Players play because there is essentially instant gratification for a click. However in order to keep the cycle going each click must provide a bigger reward then the previous click. Then the game starts making clicks itself (these games are called idle games for a reason), the game can often click much faster then the player can.

Most of the time there are plenty of design tricks to stop the numbers getting out of hand. One of the most common is the idea of prestigeing. Every few days the player is encouraged to reset the entire game for some special bonus.

But managing big numbers is a real concern. And many naive implementations of the idle game do actually break because they have overflowed the limits for whatever data type they are using.

I don’t get that. Do you have an example of a game that illustrates that?

Choose your poison

http://www.kongregate.com/idle-games?sort=rating

These games are absolutely terrible. But they are surprisingly addictive.