GM:S 1.4 Binaries / Bytes ... performance and structural optimization.

Discussion in 'Advanced Programming Discussion' started by Khanon, Mar 15, 2018.

  1. Khanon

    Khanon Member

    Joined:
    Jul 29, 2016
    Posts:
    23
    [​IMG]
    statut : *under construction*............................................version_new : 0.00 (20/03/18)
    progression : 000.01%....................................................version_old : 0.00 (15/03/18)
    usability : 000.00%..........................................................bonus code added : 0
    notice : no 3d, no internet will be concerned
    //======================================
    protocole :
    create a new project | name it as you like
    put room0 background_color to black | set the room0 dimension to ?? px height and ?? px width
    create 0 sprite
    create 0 script
    create 1 font | set font0 to text_size 22
    create 2 new objects
    put object0 anywhere in the room
    //======================================

    Code:
    //_create_event
    a=0
    for (i=0 ; i<2 ; i++) { create_instance(x,y+40*i,object1) }
    
    Code:
    //_create_event
    a=0
    Code:
    //_draw_event
    draw_text(x,y,a)
    Hi, i open a topic on binaries.
    i try to figure out how the system variables (and not the variables) handle binary transferts
    ... and by extension, how works the binaries concatenation in tcp packets (aproximate approach).
    i don't want to know how to code binary because i already know.
    what i leak is the ideal variable structure for maximize informations and performance (binary) transferts.
    So this subject is more conceptual than it appears, i will try to condensate all my knowledge and shared point of views with you in this first post. Hope it will deserve a good reflection about it. :p
    0) Basics
    .........1.0 byte = 8 bits
    .........0.5 byte = 4 bits
    .........~.1 byte = 1 bit

    Variables :
    ....are used to store information in the devices memory for later (or instant) use.
    ....can store either a real number or a string.
    ....have one name with a maximum length of 64 symbols.


    1) Recaptitulation
    >>> In GML
    Variables are all stored as
    (64-bits ?) double-precision floating point numbers, (...).====> 8 bytes (floating 4 bytes ?)
    Real numbers are all stored as 32-bits floating point values (even integer values), (...). => 4 bytes (floating 8 bytes ?)

    >>> in Mysql
    The maximum combined size of all BIT columns used must not exceed 512 bytes (of 8 bits per byte).
    4 bytes | INTEGER, INT....................................1 byte- | TINYINT
    4 bytes | FLOAT................................................2 bytes | SMALLINT
    8 bytes | FLOAT................................................3 bytes | MEDIUMINT
    8 bytes | DOUBLE............................................8 bytes | BIGINT
    8 bytes | REAL

    2) Questions and Interpretation
    => When you work with values (like toto+=1) ...
    ....about the increment " 1 " ... is it a 1 byte process ? an half-byte process ? or a mono-bit process ?
    ....about the variable " toto "... is this variable is also byte processing with the incremented value ?
    ....about bytes consumption ... are they byte floored to 1 above ? or halves-bytes are also accounted ?
    * empty*

    3) For tcp
    ... later on

    Thanks for any help about more information on this subject.
    //=============================================================
    Last update (20/03/18) <= (17/03/18) <= (16/03/18) <= ...

    yoyogames_help_manual
    Tthecreator
    dev_Mysql_docs

    If you reached the maxima integer value > go to decimal (int 1 > dec 1.0)
     
    Last edited: Mar 20, 2018
  2. Tthecreator

    Tthecreator Your Creator!

    Joined:
    Jun 20, 2016
    Posts:
    714
    Unfortunately things are a bit more complicated than that.
    In GM, all real variables are doubles. This is a special datatype that has 2 seperate parts: the number and the precision of that number.
    It's kinda like scientific notation like: 5.6 * 10^7.
    This allows you to have very small precise numbers with many decimal places, or a huge number without decimal places.
    So it's processed quite weird and I don't know exactly how but I'm guessing that the entire variable would have to be loaded into the cpu.

    I think this is what you were asking. I don't have any clue what you want to do with TCP though?
     
  3. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,044
    Here's another fact: Any bitwise operation does convert the value to a int64, also works in reverse.
     
  4. FatalSleep

    FatalSleep Member

    Joined:
    Jun 21, 2016
    Posts:
    32
    This is very oddly worded, but I think I kind of see what you're asking. So basically how does GameMaker handle variables when storing strings, numbers, etc.? And how does that affect writing and reading packets in TCP protocol?

    GameMaker uses 3 fundamental types as far as I know: string, 64-bit float and 64-bit signed integer. GameMaker uses something similar to a generic type, you give the variable an input and GameMaker determines if the input is one of the three afformentioned types. GameMaker can do bit-wise operations on the 64-bit integer type and they work as expected (except on GMS 1.4 and prior where GM would convert to 32-bit integers on bit-wise operations).

    However if you perform a bit-wise operation on a float GameMaker will truncate the decimal places and with do operations on the integer part of the number. For example if I do a left bit-shift on a float this is what'll happen:
    Code:
    var float = 1024.34098;
    float = float << 2;
    // RESULT: 4096
    
    var string = "HELLO";
    string = string & 45;
    // RESULT: 0
    
    As you can see the floating decimal 0.34098 was truncated in favor of the integer part of the number as expected. And on the string the value was ismple set to 0.

    As far as how does this affect TCP protocol: Type converstion. GameMaker will cconvert from the string, 64-bit float or 64-bit int over to whatever type you want to put in a buffer and send off over your TCP protocol and GameMaker will truncate any data that doesn't fit in the type you're converting to.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice