# Promotion 與 Cast

double PI = 3.14;

float PI = 3.14;

float PI = (float) 3.14;

float PI = 3.14F;

double PI = 3.1400000000000001D;

int number = 10;

int number = 2147483648;

long number = 2147483648;

long number = 2147483648L;

byte number = 10;

byte number = 128;

possible loss of precision

int a = 10;
double b = a * 3.14;

int i = 10;
double d = (double)i * 3.1400000000000001D;

short a = 1;
short b = 2;
short c = a + b;

possible loss of precision，你要改成這樣才對：
short a = 1;
short b = 2;
short c = (short) (a + b);

short a = 1;
long b = 2;
int c = a + b;

short a = 1;
long b = 2;
int c = (int)(a + b);

``import java.util.*;import java.text.*;// 這個程式運算結果是錯的！錯在哪？public class Main {    public static void main(String[] args) throws Exception {        DateFormat dateFormat =             new SimpleDateFormat("yyyy-MM-dd");                   Date birth = dateFormat.parse(args[0]);        Date current = new Date();        long life = current.getTime() - birth.getTime();        System.out.println("你今年的歲數為：" +                   (life / (365 * 24 * 60 * 60 * 1000)));    }}``

``public class Main {    public static void main(String[] args) {        System.out.println(Integer.MIN_VALUE == -Integer.MIN_VALUE);    }}``