shift operator with int ,float, double source code
/* This Program is a simple java Application showing that
>> ,<< cannot be used on float and double.*/
package operators;
public class ShiftNotFloat {
public static void main(String[] args) {
float a = 22.22f;
double d =33.33;
//float b= a<<2;//error ?
//int c = (int)(a <<2); //error ?
int c = (int)a <<2;
System.out.println(" c = " + c);
c = (int)d<<1;
System.out.println(" c = " + c);
}
}
output:
c = 88
c = 66
0 comments:
Post a Comment