Welcome visitors of MIC Computer

Welcome to my blog. With this blog you can post your question about computer and programming for absolutely free (free consultation sponsored by MIC Computer).. Well what are you waiting for just feel free to post your question or share with me about your computer / programming experience

Friday, October 28, 2011

PHP, Javascript, Java, and other C# style language Operators


Arithmetic Operators
Operator Description Example Result
+ Addition x=4+3 x=7
- Subtraction x=10-3 x=7
* Multiplication x=2*9 x=18
/ Division x=6/2
y=5/2
x=3
y=2.5
% Modulus (division remainder) x=7%2
y=9%3
z=10%4
x=1
y=0
z=2
++ Increment x=8;
x++;
x=9
-- Decrement x=8;
x--;
x=7
Assignment Operators
Operator Example Equivalent
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y
Comparison Operators
Operator Description Example
== is equal to 2==2 returns true
3==2 returns false
!= is not equal 2!=2 returns false
3!=2 returns true
<>
is not equal (only at PHP) 2<>2 returns false
3<>2 returns true
> is greater than 2>3 returns false
3>2 returns true
< is less than 2<3 returns true
3<2 returns false
>= is greater than or equal to 2>=2 returns true
2>=3 returns false
3>=2 returns true
<= is less than or equal to 2<=2 returns true
2<=3 returns true
3<=2 returns false
Logical Operators
Operator Description Example
&& and x=2
y=3 (x < 5 && y > 2) returns true
|| or x=2
y=3 (x < 1 && y > 2) returns true
! not x=2
y=3 !(x==y) returns true

No comments: