Wednesday, 18 June 2008
Firefox + Mac OS X = rock steady
Firefox 3 is out its pretty decent, been using it for a day or two and its great. It is a lot snappier and has a mac(ish) look and feel. I'm not sure about the claims on drastically lower memory usage, its still at about 280 MB main memory usage for about 145 tabs. Yes! 145. Thats about the same as firefox 2 took. And just for the record the screenshot below shows firefox 2 with 401 tabs. Yes! 401. That's the maximum I've reached, and they're all legit useful tabs opened over a long duration. If I remember correctly 401 tabs took about 350 MB space and CPU usage hovered around the 4 - 5 % mark. Like the title says rock steady.
Tuesday, 3 June 2008
Converting Bytes to Ints and back
//convert a byte to int and back
class ConvByteInt {
public static void main(String[] args) {
//signed byte
byte s_byte1 = Byte.parseByte(args[0]);
byte s_byte2 = Byte.parseByte(args[1]);
System.out.println("the bytes are: " + s_byte1 + ", " + s_byte2);
//unsigned ints (logically, -1 EOS)
int u_int1 = s_byte1 >= 0 ? s_byte1 : s_byte1 + 256;
int u_int2 = s_byte2 >= 0 ? s_byte2 : s_byte2 + 256;
System.out.println("the integers are: " + u_int1 + ", " + u_int2);
//convert them back, casts
byte a = (byte) u_int1;
byte b = (byte) u_int2;
System.out.println("the bytes are: " + a + ", " + b);
//convert them back, no casts
//representation 0 - 255 (unsigned ints)
//does NOT check boundary conditions
//are the bit operations even needed ??
byte c = (byte) ((u_int1 & 0x000000FF) <= 127 ? u_int1 : u_int1 - 256);
byte d = (byte) ((u_int2 & 0x000000FF) <= 127 ? u_int2 : u_int2 - 256);
System.out.println("the bytes are: " + c + ", " + d);
}
}
sample out-
17864397:io anujseth$ java ConvByteInt 43 -12
the bytes are: 43, -12
the integers are: 43, 244
the bytes are: 43, -12
the bytes are: 43, -12
Subscribe to:
Posts (Atom)