类型检查
2018-06-17 本文已影响0人
是阿冰喔
Ø 静态检查:类型types
动态检查:值values
Ø Java和许多其他编程语言中的一个点是 它的原始数值类型有特例, 表现得不像我们习惯的整数和实数。因此,应该动态检查一些错误 根本不检查。
– Integer division: 5/2 does not return a fraction, it returns a truncated
integer.
– Integer overflow. If the computation result is too positive or too negative
to fit in that finite range, it quietly overflows and returns a wrong answer.
(no static / dynamic checking!) e.g., int big = 200000*200000;
– Special values in floating-point types. NaN (“Not a Number”),
POSITIVE_INFINITY, and NEGATIVE_INFINITY. e.g., double a=7/0;