Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
What is the largest number in lua? — Gideros Forum

What is the largest number in lua?

totebototebo Member
edited May 2015 in General questions
A 64 bit integer is 19 digits long, and used by Gamekit and Google Play as a max value for scores.

Is this supported by lua? If not, which is the largest number supported?
My Gideros games: www.totebo.com

Comments

  • totebototebo Member
    edited May 2015
    My scores are coming out as 2,147,483,647, which most likely means that Gideros Lua doesn't support 64 bit integers. Bummer!

    Interestingly I found in Lua 5.3 reference manual that it supports 64 bit integers.
    Standard Lua uses 64-bit integers and double-precision (64-bit) floats, but you can also compile Lua so that it uses 32-bit integers and/or single-precision (32-bit) floats.
    Which version of Lua does Gideros use? If not 5.3, could it be updated?

    My Gideros games: www.totebo.com
  • totebototebo Member
    Does anyone know which Lua version gideros uses?
    My Gideros games: www.totebo.com
  • ar2rsawseenar2rsawseen Maintainer
    I think it was 5.1, as stated in the repo:
    https://github.com/gideros/gideros/tree/master/lua

    but if you use luajit I think it might be different, might be even cpu specific
  • talistalis Guru
    edited May 2015
    Ok not %100 sure but after writing
    print(_VERSION)
    in the main.lua it printed me:

    Lua 5.1

    So i guess 5.1 with the 2014.10 Gideros Studio. So just try with your Gideros version to find out the Lua version.

  • SinisterSoftSinisterSoft Maintainer
    edited May 2015
    LuaJIT can also be used, it has a different (wider?) range...

    http://bitop.luajit.org/semantics.html

    "Hexadecimal literals are treated as unsigned numbers by the Lua parser before converting them to the Lua number type. This means they can be out of the range of signed 32 bit integers if the Lua number type has a greater range. E.g. 0xffffffff has a value of 4294967295 in the default installation, but may be -1 on embedded systems."
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • hgy29hgy29 Maintainer
    I guess that lua number would be 32 bits on 32 bits archs and 64 bits on 64 bits archs...
  • totebototebo Member
    edited May 2015
    Thanks guys.


    The latest Gideros build, 2015.05.09, uses Lua 5.1. I can confirm Lua 5.1 does not support 64 bit integers. This means it can't take advantage of the 64 bit scoring system in Gamekit and Google Play.

    @hgy29, I am testing this on an iOS 64 bit build, but Lua appears to restrict it to 32 bit.


    image

    Questions, questions:

    1. Can Gideros be upgraded to use Lua 5.3? If so, is this something that would be considered by the Superhero Core Team?
    1.1. If not, could the LNUM patch be applied to the current Gideros Lua 5.1? https://github.com/LuaDist/lualnum
    1.2. If not, is there a neat workaround for this issue? One solution could be to rewrite, or extend, the Gamekit and Google Play services to work with strings as well as 32 bit integers.
    2. LuaJIT. Will using it allow 64 bit integers?

    Look forward to thoughts on this, especially from the Core Team.

    Niclas
    rutger-hauer-as-roy-batty-in-blade-runner.jpg
    1257 x 589 - 62K
    My Gideros games: www.totebo.com
  • hgy29hgy29 Maintainer
    We are thinking about moving to luajit, main concern being that lua files should not be exported in readable format and that parsing itself should be avoided in mobile platforms. When/if we do this I am pretty sure we will use the latest version available to us. @SinisterSoft is thinking about this move since some time now...

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited May 2015
    LuaJIT appears to support a much larger range than standard Lua 5.1 (56 bit?)

    x=0xffffffff
    print(x)
    x=x+0x10000000000
    print(x)
    x=x-0x10000000000
    print(x)

    results in:
    main.lua is uploading.
    Uploading finished.
    4294967295
    1103806595071
    4294967295

    Those numbers are large enough for a score for me. :)

    I don't know what the support is though with regard to getting the >32 bit number out of Lua and into Google Play.

    - Anthony


    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • totebototebo Member
    @hgy29 okay, thanks for clarifying.

    @SinisterSoft 13 digits, that's good!

    The idea is sending a score that also contains data about the previous game session, so a separate database is not needed for that. I could then use that to show data from friends' scores effortlessly and cheaply. That's why I was hoping to use more than 10 digits. Greedy! :)

    My Gideros games: www.totebo.com
  • SinisterSoftSinisterSoft Maintainer
    It looks like it's accurate to 56 bits.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • SinisterSoftSinisterSoft Maintainer
    You should use the lower bits for extra info if you are using facebook score - that way you can divide it and the scores still stay in order.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • totebototebo Member
    Thanks Sinister. In the end I chose to modify gamekit.mm to accept strings, which works well in this case. For the save state to work I needed 18 digits in the end. :)
    My Gideros games: www.totebo.com
Sign In or Register to comment.