Integer limit

VmlwebVmlweb Member Posts: 427
edited November -1 in Working with GS (Mac)
Hey

Is there any limit to the size of the number that can be stored in an Integer?

Because I am making a number encoding system in my game which can store multiple numbers in 1 number and can add to a given number or can extract it.

This way I can store the highscores for the whole game in 1 attribute and have 1 rule that checks if there is a new highscores instead of 30 rules.

Thanks,
Vmlweb

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    The Developers will probably have to chime in here, but typically the range for an Integer stored in a database (which I believe this is) is from -2147483648 to 2147483647.
  • iDeveloperziDeveloperz Member Posts: 1,169
    An integer goes up is from -32768 to 32767 on a 16 bits. What mulcahy said is called a longInteger (32 bit).
  • VmlwebVmlweb Member Posts: 427
    I'm on my iPhone at the moment so could someone pls test this out
    try storing a number bigger than mulcahey said in a integer
  • ORBZORBZ Member Posts: 1,304
    it's a 32bit int, +/- aprox 2billlion.

    Google the wiki on 32bit integers.

    These are unsigned...

    Oddly enough Indexes (aka Integers that can only be positive) still only go up to positive 2bil, not 4billion as would be expected from an unsigned int.

    I would be very curious to see how you encode the values. I was trying to do something similar before but gave up on it due to lack of bitwise operators in Lua.
  • VmlwebVmlweb Member Posts: 427
    Are index numbers larger than integers?
  • ORBZORBZ Member Posts: 1,304
    no, index numbers are just signed integers without negative values, thus they throw away half their value.

    floats are bigger than ints.

    Try it... take an int, assign it 2billion or so, and then put it inside a really fast timer that adds 1000 to it every nanosecond. DisplayText and watch the value climb. At 2^32-1 it will start to wrap and the value will begin to count down.

    I'm soo curious what your encoding scheme is though. Like I said before, I tried to do this but without bitwise operators I gave up.
  • VmlwebVmlweb Member Posts: 427
    Ok I'll post it in a min
    It also looks like it has a limit. That limit can be increased by setting the value of the number down
Sign In or Register to comment.