Object numbers

An object number is the unique number assigned to every object in an Active World. Because these numbers are integers and can be very large, the AW SDK uses unsigned values for them. However, for simplicity all numeric values are treated as floating point in Magsbot. Because of this, the large unsigned values of object numbers sometimes appear as negative integers in Magsbot.

You may have noticed that when Magsbot logs build or click events, there are two numbers given, like

    Magine clicked on object 2810933501 (-1484033795)

The first number is the "unsigned" object number, which is what you would see in a survey. The second number (which may not always be different) is the "signed" value; if it's different from the first number, then it will be negative.

The only thing you really need to remember here is that when using Magsbot commands or functions, you should either use the second (signed) number, or else use the @int function to convert to a signed value.

So, in a Behavior Table events column, for instance, either of these would be correct:

    OBJECTCLICK @objnum=-148033795
or
    OBJECTCLICK @objnum=@int[2810933501]

You can also use the @uns function to convert signed values to unsigned.

Signed and unsigned numbers

You don't need to know any of the information below in order to use Magsbot, but in case you are curious about what "signed" and "unsigned" numbers are all about, here's a quick lesson in computer math. :)

As you probably know, computers store all numbers as strings of bits (0's and 1's). A byte is a string of 8 binary digits, for instance "7" is 00000111. Using this system, one byte can represent any number from 0 (00000000) to 255 (11111111). But what about negative numbers? If need to use negative numbers then the same byte can represent numbers from -128 to 127 instead of 0 to 255, by considering the leftmost bit to be the sign (0=positive, 1=negative). There are several different systems for doing this, but the method that PC's use is to flip all the bits (change 0 to 1 and vice versa) and add 1, to change the sign of the number. (The reason they use this system instead of just changing the leftmost bit is because arithmetic comes out correct when you represent negative numbers that way.) So, using signed numbers, 7 would still be 00000111 but -7 would be 11111001. Notice the leftmost bit of -7 is 1.

What all this means is, the same byte can represent different values depending on whether or not you are considering it to be "signed" or "unsigned".  The binary number 11111001 can be -7 or 249 depending on what system you're using. The same principle is applied to numbers larger than a byte, so, for instance, the four-byte (32 bit) number 10100111100010110111000011111101 can be -148033795 or 2810933501 depending on whether you consider it "signed" or "unsigned".

Back to Functions.