Pages

2012-01-06

Signed Int in Java

while the code in java sometimes i wanted to use signed integer type. but like C++ coudn't find a way to use signed int.  so thought about a way to convert negative integers to positive.

int integerVariable;
integerVariable =-20;
//now convert negative values to positive
if(integerVariable<0)
     integerVariable=0-integerVariable;


now just use integerVariable as your wish. it will only contain positive values.

2 අදහස්:

මෙම ලිපිය කියවනකොට හිතුණු දේවල් වලින් ටිකක් මෙතන ලියලම යන්නකෝ