How do I work with big numbers

0 favourites
  • 12 posts
From the Asset Store
Jump over the small square and avoid hitting it as long as you can!
  • Hi,

    i am working on a clicker game, so very big numers are essential. Unfortunately it seems that Construct2 has a number max limit of 9223372036854776000. How do i manage numbers that are much more bigger. In Javascript that isn't a problem at all:

    p.e. 9223372036854776000 * 119892 = 1.1058085202425928e+24.

    Impossible in Construct2

    Somebody has an idea? Thanks in advance

  • As speed isn't an issue, you could represent numbers as strings and write code in functions to process them. Ideally you would use arrays but they probably aren't flexible enough.

  • Numbers in C2 are 64bit floating point values so it can handle values like that.

    The editor doesn't let you type numbers with scientific notation so maybe that's where the misunderstanding is.

  • If it is 64 bit, then there are 63 bits + sign bit. Given you can't back a 10 digit value into 3 bits this puts an upper bound on the number of digits at 21, and ByteMonkey's number is 24 digits long.

  • Here are the specs:

    https://en.wikipedia.org/wiki/Double-pr ... int_format

    1 bit for sign, 11 bits for exponent, and 52 bits for the fraction.

    With that it's only 15-17 significant decimal digits, but since it also stores an exponent it can store a value up to:

    1.7976931348623157 × 10^308

    which is plenty for a clicker game.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you use a whole number in an expression, C2 treats it as an integer and truncates it. If your numbers are stored in variables it's not a problem.

    set text to 999999999999 * 999999999999   
    => 2003762205206896600
    
    num1 = 999999999999
    num2 = 999999999999
    set text to num1 * num2
    => 9.99999999998e+23
    [/code:358333yf]
    
    If you want to use a large number in an expression, use a float:
    [code:358333yf]
    set text to 999999999999.0 * 999999999999.0
    => 9.99999999998e+23
    [/code:358333yf]
  • Hi, For that same example of an incremental game that is asked above, how i show the score in just a few digits and an exponent?

    The exponent counts as the same number and is indivisible or it counts as text or a string?

    How i show all the numbers as numbers with exponents, even the smaller ones, like for example to show on a text object: 1*10^6 or 1*10^7 ?

    Is it a simple way to display this without using Rex's CSV tool or any other plugin?

    Thanks

  • Why you doesn't round them and use K M B T TT etc?

    As far as i remember, many games do this for sake of legibility.

  • If you have a number in a variable n, you can do this:

    e= int(log10(n))

    set text to int(1000*n/10^e)/1000&"x10^"&e

  • I've seen a few games just use their own system, bazillion, gazillion, omgerzillion.

  • I've seen a few games just use their own system, bazillion, gazillion, omgerzillion.

    Yep, thats what im talkin about.

    Even Diablo 3 rounds it (but the dmg/HP is still at T hehehe)

  • Thanks both of you Cassianno , R0J0hound, and newt for your answers.

    I think i'm going to follow R0J0hound advice on the e= int(log10(n)) . I was asking for a simple way of depicting this, and this looks good. I still have to test it on my project, but looks good.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)