Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Strange operators (https://forums.graalonline.com/forums/showthread.php?t=63453)

Yen 01-15-2006 06:41 AM

Strange operators
 
Explain these to me! Please.
NPC Code:
Bitwise-Or                a | b
Bitwise-And a & b
Bitwise-Shift left a << b
Bitwise-Shift right a >> b
Bitwise-Invert ~a
Bitwise-Xor a xor b (operator ^ already used for power)
Bitwise-Or Assignment a |= b
Bitwise-And Assignment a &= b
Shift Left Assignment a <<= b
Shift Right Assignment a >>= b



Also, why do people use := sometimes, instead of =?

Lance 01-15-2006 07:32 AM

They aren't strange. Honestly, there is a big internet out there and some pages actually exist to explain such things. And, there are even tools which make locating these pages quick and easy. Imagine that!

Yen 01-15-2006 08:10 AM

>_> I tried that. I couldn't find much on what they do, just big formulas.. That were really confusing.

Chicken_l33t 01-15-2006 09:23 AM

http://en.wikibooks.org/wiki/Program...harp/Operators

Here's some I found in C#, i'm sure they will have the same principles in GS2.


Quote:

Also, why do people use := sometimes, instead of =?
I'm not 100% sure on this one, but I believe it's to do thinks like..

From this: a = a + 1
to this: a := +1

Something like that, as I said i'm not sure, and I havent actually tryed because I just use a = a + 1 :P

Rick 01-15-2006 09:46 AM

No, := is the same thing as =. In Delphi, assignment is done with :=.

As for the bit operators, they adjust the bits in a number.

A google of 'bitwise operators' produces plenty of pages explaining them.

Such as : http://download.cdsoft.co.uk/tutorials/bitops/

Prozac 01-15-2006 08:01 PM

i haven't seen := used as an assignment operator since I took classes in Pascal. Good memories. C++ and Gscript are better tho.

Rick 01-15-2006 10:40 PM

Quote:

Originally Posted by Prozac
i haven't seen := used as an assignment operator since I took classes in Pascal. Good memories. C++ and Gscript are better tho.

:= is valid in GScript2.

adam 01-16-2006 06:26 AM

Quote:

Originally Posted by Yen
Explain these to me! Please.
NPC Code:
Bitwise-Or                a | b
Bitwise-And a & b
Bitwise-Shift left a << b
Bitwise-Shift right a >> b
Bitwise-Invert ~a
Bitwise-Xor a xor b (operator ^ already used for power)
Bitwise-Or Assignment a |= b
Bitwise-And Assignment a &= b
Shift Left Assignment a <<= b
Shift Right Assignment a >>= b



Also, why do people use := sometimes, instead of =?

Maybe this will help

Bitwise Operators (GameDev)

jake13jake 01-16-2006 03:20 PM

Quote:

Originally Posted by Yen
Also, why do people use := sometimes, instead of =?

It's the same thing as =, unfortunately.

It would be nice if this operator was given unique functionality as a "delayed assignment operator," meaning not to assign the value until the next time it's modified (kindof like preincrement, but more in a sense of preassignment). Considering it's definition in the language is already defined, though.. doubt it will change. The question of modify it to behave this way would be, would you want to save the value that it would be assigned as it is called, or delay the execution until the assigned operator is modified.

ApothiX 01-16-2006 03:42 PM

Quote:

Originally Posted by jake13jake
It's the same thing as =, unfortunately.

It would be nice if this operator was given unique functionality as a "delayed assignment operator," meaning not to assign the value until the next time it's modified (kindof like preincrement, but more in a sense of preassignment). Considering it's definition in the language is already defined, though.. doubt it will change. The question of modify it to behave this way would be, would you want to save the value that it would be assigned as it is called, or delay the execution until the assigned operator is modified.

Of course, because you know.. there aren't scripts writtin using := that would completely screw up if they changed what the operator does.

jake13jake 01-16-2006 09:45 PM

Quote:

Originally Posted by ApothiX
Of course, because you know.. there aren't scripts writtin using := that would completely screw up if they changed what the operator does.

That's quite exactly what I'm saying. Don't think you needed to reiterate.


All times are GMT +2. The time now is 08:37 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.