What these sign do?
#1

I seen in fuction this sign -

number >>= 4;


I am look for more special signs like these....... and I am not find guide for these, can you give me? Thanks
Reply
#2

EDIT: Wrongly understood.
Reply
#3

Shift the number to the right with 4 bits.

Example: number is 16. We need to convert that to binary first. That's 0b10000.
Now we shift all the bits to the right 4 times. The output will be: 0b00001 in binary, which is 1 in decimal.

It really only makes sense when you're working with bits in your gamemode. Here's some documentation about it: https://sampwiki.blast.hk/wiki/Binary#Binary_operators
Reply
#4

Thank you !

if I look in the table in Binary operators I can see -

& bitwise and, that mean can I use it only with binary number, and not with regular number, and with && I can't use in binary number but with regualr number?

I mean I can't do -

PHP код:
if(0001 == && 0010 == Y
PHP код:
And I can't do - 
if(2 == X & 3 == Y)

?


Another question -

I seen in function this -
PHP код:
stock GetDateOffeset(&year,&month,&day,offset
What is the & symbol here ?

Thanks
Reply
#5

Quote:
Originally Posted by tal_peretz
Посмотреть сообщение
Thank you !
Another question -

I seen in function this -
PHP код:
stock GetDateOffeset(&year,&month,&day,offset
What is the & symbol here ?

Thanks
& returns the adress of a variable so the function can set a value on the given adress.

if you want more info I would like to redirect you to http://www.cplusplus.com/doc/tutorial/pointers/

Quote:

The memory of your computer can be imagined as a succession of memory cells, each one of the minimal size that computers manage (one byte). These single-byte memory cells are numbered in a consecutive way, so as, within any block of memory, every cell has the same number as the previous one plus one.

This way, each cell can be easily located in the memory because it has a unique address and all the memory cells follow a successive pattern. For example, if we are looking for cell 1776 we know that it is going to be right between cells 1775 and 1777, exactly one thousand cells after 776 and exactly one thousand cells before cell 2776.

Reply
#6

1. replace == with &
2. its a pointer, ****** this pls, im with pda online cant post a link

tion
Reply
#7

Quote:
Originally Posted by tal_peretz
Посмотреть сообщение
I seen in fuction this sign -

number >>= 4;


I am look for more special signs like these....... and I am not find guide for these, can you give me? Thanks
Its an arithmetic right shift. There is a "guide" in my signature :P.


Edit Judging from your response about the bitwise AND operator, i think you need to read my binary topic even more :P.

The "&" symbol in front of the function parameters is called a reference. When a parameter is passed by reference the function is able to actually modify the variable's value outside of the function (meaning any changes to the parameter inside the function are kept (look at GetPlayerPos - thats how the function modifies the X,Y,Z variables we pass to it). Keep in mind that strings are naturally passed by reference, meaning if you pass a string it can be modified; in order to stop this use the keyword "const".

This is not a pointer like someone above me said.
Reply
#8

So to do if(x==3) its like to do if(x&3)?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)