[Tutorial] Arithmetic Symbols.
#1

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.
Reply
#2

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
Reply
#3

Quote:
Originally Posted by Kyosaur
View Post
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 ?
Reply
#4

Nice but isn't there a way to do like

pawn Code:
#define * x
So instead of * you can put x or what ever i want?
Reply
#5

You should probably revise the pawn-lang.pdf before writing a tutorial on arithmetic operators/symbols.

Quote:
Originally Posted by willsuckformoney
View Post
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?
Reply
#6

Quote:
Originally Posted by willsuckformoney
View Post
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 ^^
Reply
#7

Quote:
Originally Posted by The Toni
View Post
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.
Reply
#8

Quote:
Originally Posted by Kyosaur
View Post
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.
Reply
#9

Quote:
Originally Posted by Kyosaur
View Post
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
View Post
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
View Post
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).
Reply
#10

Quote:
Originally Posted by Calgon
View Post
What's with your obsession with cheesy signatures? Lol.
Hehe im just a cheesy guy .
Reply
#11

Very helpful, thanks
Reply
#12

It'd be around time a decent tutorial would've been posted here again. Good job Toni :P
Reply
#13

Quote:
Originally Posted by The Toni
View Post
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.
Reply
#14

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
Reply
#15

Thanks for being honest Y_Less. I'll try to read a little more.

After that, I'll edit the tutorial.
Reply
#16

Sorry for refreshing this old theme.
I have one question.
What represent "+="
Thanks!
Reply
#17

I don't think that there is kind of symbol.
Try using =>, <=, >, <.
Reply
#18

Quote:
Originally Posted by David Skrbic
View Post
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;
Reply
#19

Thanks i know now:
Code:
somefunc()
{
    new var = 12;
    var += 2;
    printf("Var: %d", var);//Will print 14 
}
Reply
#20

Good job, this is useful and has many information , thanks you
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)