Author Topic: About these X= signs...  (Read 754 times)

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
About these X= signs...
« on: July 26, 2010, 10:03:18 pm »


               So far += and -= has been good enough for me, but...

I just noticed that *= and /= doesn't return an error when compiling. I assume they work since they are the most obvious and common math operations, but then I started testing...

&=
%=
$=
@=
'=
...Do not return an error either. Does anyone know what are they used for?

Also ^= compiles fine... I assume this is used to raise a number to an exponent...
If it is so, what is the point of the pow( ) function?

And last but not least, is there difference between /= and \\\\=  ?     (Both compile)

EDIT

For some reason the forums add a second slash ( \\\\ ) even though I only type one...

EDIT

Oh I give up... Now it's throwing them all over the place.
               
               

               


                     Modifié par Xardex, 26 juillet 2010 - 09:05 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
About these X= signs...
« Reply #1 on: July 26, 2010, 10:46:33 pm »


               Some of those should work.



a += b is the same thing as a = a+b



So, a /= b is the same as a = a/b



Check out this link: C++ Operators and scroll down to "Compound assignment" for a list.



You can always set up a script that returns values for each of those operators you listed and see what you get.



-420
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
About these X= signs...
« Reply #2 on: July 26, 2010, 11:16:05 pm »


               Well that site gives some good info, but I doubt I'll ever have use for others then -+*/...
That link doesnt explain though what '= $= &= @= are for... Just wondering. (Curiosity) '<img'>

EDIT

It seems I need to edit my post twice for the edit to actually happen... I already miss the good ol' bioware forums! ':pinched:'
               
               

               


                     Modifié par Xardex, 26 juillet 2010 - 10:19 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
About these X= signs...
« Reply #3 on: July 26, 2010, 11:21:33 pm »


               

Xardex wrote...

So far += and -= has been good enough for me, but...

I just noticed that *= and /= doesn't return an error when compiling. I assume they work since they are the most obvious and common math operations, but then I started testing...


yes this is most likely what you are thinking it is.

x *= 5;  is the same as x=x*5 ;
x /= 5 ; is the same as x=x/5;

&=
%=


again about the same you just need to know what the operators are.

x &=; is the same as x=x & 5;  This will do a bitwize And between x and 5. unlike the logical And(&&) that returns just true or false. (1 or 0) the bit wize And(&) will a logical and on every bit position in the number.  

so if x = 260. 
x &= 5 would return a value of 4 for x.  That being the only bit the two numbers have in common.  

the %= is a modulous  so
x %= 5  would be the same as x = x % 5;  it returns the remainder of the devision of x and 5.  so it x was initinaly 6 the remainder  would be 1.

$=

I do not know that the $ operator does in NWN.  I have speculated on it in the past though.
 

@=
'=

it has been speculated that the @ is a compiler directive.  I have no idea what your number would evalute to. I may have to play with this one a bit more since this will compile. 
the '=  do not have a clue.  
 

...Do not return an error either. Does anyone know what are they used for?

the unknown ones above may just be compiler bugs returning unknown values to the varaiable.  along with the other unknown one below.  the \\=.

Also ^= compiles fine... I assume this is used to raise a number to an exponent...
If it is so, what is the point of the pow( ) function?

 

This one you have wrong.  In NwN script the carrot(^) is not a to the power of operator.  It is a Bitwize  ExclusiveOr Operator.  

So x ^= 5;  is the same as x = x^5;  that is the Exclusive Or between all the bits positions of x and 5; 

rounding out that set you missed on the Or =   

|= 

Hope that all help.   

 
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
About these X= signs...
« Reply #4 on: July 27, 2010, 12:09:38 am »


               

Xardex wrote...
It seems I need to edit my post twice for the edit to actually happen... I already miss the good ol' bioware forums! ':pinched:'

It happen but its not reloaded, after EDIT, try to refresh page via F5
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
About these X= signs...
« Reply #5 on: July 27, 2010, 09:13:48 am »


               Thanks for the info Lightfoot....
I seriously doubt anyone has had any use for these special operators in a non-test script.

And Shadooow, I did refresh many times but the post just didnt get edited until I pressed 'Edit -> Submit' again...
               
               

               
            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
About these X= signs...
« Reply #6 on: July 27, 2010, 12:53:00 pm »


               I think there's a time delay on how long you have to wait for edits to show up.  If I try to edit a new post I just made, I have to wait a little while for the edit to appear.  However, if I go back to a post that I did before, the edit appears immediately.  I haven't tried two edits in a row on an older post, yet.