This is some information on the Java 6 certification that I prepare. This information is not very well structured and it is most of the time an answer to the questions that come when I read the SCJP 6 book (Bates and Sierra). *** AS OF 5 OF MARCH 2010, I AM SCJP 6.0 ***

Monday, January 4, 2010

2 - Numerics

// apply 2-complement
//-2^(range-1) to 2^(range-1)-1
// there is 1 negatif more
// there is 1 positif less

// 8 bits signed
byte byteMin=-128;
byte byteMax=127;
//byte b0 = 128; does not compile
//byte bo=-129; does not compile

// 16 bits signed
short shortMin=-32768;
short shortMax=32767;
//short s0=-32769; does not compile
//short s0=32768; does not compile

// 16 bits unsigned
char charMin=0;
char charMax=65535;
//char c0=-1; does not compile
//char c1=65536; does not compile
char c2=65;
System.out.println("c2 : " + c2); // A
char c3='A';
System.out.println("c3 : " + c3);

// 32 bits signed
int intMin=-2147483648;
int intMax=2147483647;
//int i0=-2147483649; does not compile
//int i1=2147483648; does not compile

// 64 bits signed
long longMin = -9223372036854775808L;
long longMax = 9223372036854775807L;
//long l0=-9223372036854775809L; does not compile
//long l1=9223372036854775808L; does not compile

// 32 bits floating point
float floatMin=-2147483648f;
float floatMax=2147483647;
//float f0=-2147483649f; does not compile
//float f1=2147483648f; does not compile
float f2=1.0f; // f is mandatory because 1.0 is a double !!!
float f3=1.0e38f;
//float f4=1.0e39f; too large does not compile

// 64 bits floating point
double doubleMin=-9223372036854775808l; // L is mandatory because it is seen without as an integer
double doubleMax=9223372036854775807l;
//double d0=-9223372036854775809l; does not compile
//double d1=9223372036854775808l; does not compile
double d2=1.0e308d; // max
//double d3=1.0e309d; too large does not compile

No comments:

Post a Comment