I need some help!
so at first... this is about c#... but at least c syntax(it may not differ on e.x. c++..)
here's some code (can be found in Color.cs)[irrnetCP Types]:
Code: Select all
public int NativeColor
{
get
{
return ((A & 0xff) << 24) |
((R & 0xff) << 16) |
((G & 0xff) << 8) |
(B & 0xff);
}
set
{
A = (value >> 24) & 0xff;
R = (value >> 16) & 0xff;
G = (value >> 8) & 0xff;
B = (value) & 0xff;
}
when i first looked at that, i had some questions like:
what the *** is that: >>, <<, | and 0xff ???
then i searched a lil'bit and found these:
">>" is and Operator called right shift-ing (or whatever) ..
i read some things about it on msdn, but couldnt really understand(because of my low english/ computer knowledge)
BUT how the * could i get this:
Code: Select all
int i = -1000;
Console.WriteLine(i >> 3);
//...returns:
//-125
..like i have a number and i can write in this 0x*****... ?
| is of course logical.. but when im dealing with bits is called BITWISE logic... and as i could understand: it's like mergeing( ) 2 bits..
so at the end i could find this out:
when i call this:
Code: Select all
return ((A & 0xff) << 24) |
((R & 0xff) << 16) |
((G & 0xff) << 8) |
(B & 0xff);
SO... could you answer my last questions:
- aim i right?
how can i translate an int to 0x*****?
make me understand using shifting!