Arithmetic Operators -
Toni - 09.09.2010
Arithmetic Operators
These are operators used everyday, or at least most of them are. In SA:MP's case being used inside PAWN, they are probably used like every other piece of code, used for calculating different things such as height, width, length and position. Math in these languages are common and are used for various items!
Operator | | | Definition | | | Example |
+ | | | Addition: Increasing numbers resulting with a sum. | | | 5 + 5 = 10 |
- | | | Subtraction: Decreasing numbers resulting with a difference. | | | 10 - 5 = 5 |
/ | | | Division: Decreasing numbers resulting with a quotient. | | | 10 / 2 = 5 |
* | | | Multiplication: Increasing numbers resulting with a product. | | | 5 * 2 = 10 |
> | | | Greater than: Used to compare two values; the left value is being stated as larger. | | | 10 > 2 |
< | | | Less than: Used to compare two values; the right value is being stated as larger. | | | 2 < 10 |
>= | | | Greater than or equal to: Same as '>' but accepts numbers that are also equal to the same value. | | | x = 10; x >= 10 |
<= | | | Less than or equal to: Same as '<' but accepts numbers that are also equal to the same value. | | | x = 10; x <= 10 |
Thank you for taking time to read this, and please reply to the topic on any suggestions / errors I have made in this topic! I for sure don't know everything, and so I'm just doing my best when learning new things and putting this up for other people to learn from.
Re: Arithmetic Symbols. -
Kyosaur - 09.09.2010
What a coincidence, im in the middle of writing a binary tutorial which explains a lot of you "dont know" operators. Its not quiet finished, but you should probably check it out:
https://sampwiki.blast.hk/wiki/Binary
Re: Arithmetic Symbols. -
Toni - 09.09.2010
Quote:
Originally Posted by Kyosaur
What a coincidence, im in the middle of writing a binary tutorial which explains a lot of you "dont know" operators. Its not quiet finished, but you should probably check it out:
https://sampwiki.blast.hk/wiki/Binary
|
Very nice, I'll start reading, and add your code + you link.
Btw, do you know why I can't create a account on the wiki ?
Re: Arithmetic Symbols. -
willsuckformoney - 09.09.2010
Nice but isn't there a way to do like
So instead of * you can put x or what ever i want?
Re: Arithmetic Symbols. -
Calgon - 09.09.2010
You should probably revise the pawn-lang.pdf before writing a tutorial on arithmetic operators/symbols.
Quote:
Originally Posted by willsuckformoney
Nice but isn't there a way to do like
[/pawn]
#define * x
[/pawn]
So instead of * you can put x or what ever i want?
|
You realize that whenever you use the 'x' letter, it'll be replaced?
Re: Arithmetic Symbols. -
Toni - 09.09.2010
Quote:
Originally Posted by willsuckformoney
Nice but isn't there a way to do like
[/pawn]
#define * x
[/pawn]
So instead of * you can put x or what ever i want?
|
Yes you could, but I wouldn't recommend doing that.
Every X you do in the server would be a multiplication sign, e.g Float:X will do x times etc.
You also got it backwards lol, #define X *
Edit; Calgon beat me ^^
Re: Arithmetic Symbols. -
Kyosaur - 09.09.2010
Quote:
Originally Posted by The Toni
Very nice, I'll start reading, and add your code + you link.
Btw, do you know why I can't create a account on the wiki ?
|
Registration has been disabled due to the posting of shock/gore porn D:
EDIT: Colgon beat me on the define thing :P.
Re: Arithmetic Symbols. -
Toni - 09.09.2010
Quote:
Originally Posted by Kyosaur
Registration has been disabled due to the posting of shock/gore porn D:
|
Damn it i knew i should have registered WAY earlier.
But good job on your binarys...i'm still confused, but getting there.
Re: Arithmetic Symbols. -
Calgon - 09.09.2010
Quote:
Originally Posted by Kyosaur
Registration has been disabled due to the posting of shock/gore porn D:
EDIT: Colgon beat me on the define thing :P.
|
What's with your obsession with cheesy signatures? Lol.
Quote:
Originally Posted by Kyosaur
What a coincidence, im in the middle of writing a binary tutorial which explains a lot of you "dont know" operators. Its not quiet finished, but you should probably check it out:
https://sampwiki.blast.hk/wiki/Binary
|
Epoch!
Quote:
Originally Posted by The Toni
Damn it i knew i should have registered WAY earlier.
But good job on your binarys...i'm still confused, but getting there.
|
Registration will probably get opened again in the future, or you could consider asking a SA-MP moderator to register you an account (if they allow that).
Re: Arithmetic Symbols. -
Kyosaur - 09.09.2010
Quote:
Originally Posted by Calgon
What's with your obsession with cheesy signatures? Lol.
|
Hehe im just a cheesy guy
.
Re: Arithmetic Symbols. -
dirkblok - 09.09.2010
Very helpful, thanks
Re: Arithmetic Symbols. -
Hiddos - 09.09.2010
It'd be around time a decent tutorial would've been posted here again. Good job Toni :P
Re: Arithmetic Symbols. -
Y_Less - 09.09.2010
Quote:
Originally Posted by The Toni
But I'd like to see what Y_Less has to say to this topic...he'll probably have those really long but helpful information paragraphs.
|
Of course!
Firstly your division symbol is backwards. You may also want to explain the difference between integer and float division: "15 / 2 = 7" in ints and "7.5" in floats.
List of symbols you missed (and you REALLY need to read pawn-lang to see what symbols do before posting a tutorial stating that you don't know what they do, there's not really much point in that is there)?
>>> (not >>)
^
%
- (unary)
!
*=
+=
-=
<<=
>>=
>>>=
%=
/=
|=
&=
^=
I wrote an extensive review of the symbols a long time ago, but it's long gone, shame, I know Simon loved it.
That also really didn't explain binary, and you didn't mention hex at all.
What I do when writing a tutorial is write it in a file on my PC (I have a few unpublished topics floating about). I can then take time over them and research bits I don't know, instead of producing something where I don't know half the information. Either restrict the scope of your topic to what you know or look up what you don't. If someone who doesn't know what "&" does, reading this topic is not going to help in the slightest.
Re: Arithmetic Symbols. -
Kyosaur - 09.09.2010
I made a wiki page a few days ago regarding hex, so if you want to read up on it:
https://sampwiki.blast.hk/wiki/Hex
Re: Arithmetic Symbols. -
Toni - 09.09.2010
Thanks for being honest Y_Less. I'll try to read a little more.
After that, I'll edit the tutorial.
Re: Arithmetic Symbols. -
MicroD - 22.08.2011
Sorry for refreshing this old theme.
I have one question.
What represent "+="
Thanks!
Re: Arithmetic Symbols. -
Darnell - 22.08.2011
I don't think that there is kind of symbol.
Try using =>, <=, >, <.
Re: Arithmetic Symbols. -
Adil - 22.08.2011
Quote:
Originally Posted by David Skrbic
Sorry for refreshing this old theme.
I have one question.
What represent "+="
Thanks!
|
This is used for changing a value of a variable, with something added to it's current value.
For example:
Code:
new variable;
variable = 32;
//This is what you will do to add 6 into the current value of the variable
variable += 6;
Re: Arithmetic Symbols. -
MicroD - 22.08.2011
Thanks i know now:
Code:
somefunc()
{
new var = 12;
var += 2;
printf("Var: %d", var);//Will print 14
}
Re: Arithmetic Symbols. -
Naruto_Emilio - 23.08.2011
Good job, this is useful and has many information
, thanks you