Number Literals
- Integer Literals, Floating-Point Literals 등을 포괄하는 의미
Integer Literals
- Integer Literal은 Integer Variable(정수 자료형)에 할당될 수 있다.
- Literal 값이 Variable의 최대 할당 크기를 초과하면 컴파일 오류가 발생한다.
long type를 명시적으로 표현하려면 L 또는 l을 붙인다. (ex: long longVal = 3141592L;)
Floating-Point Literals
- 기본적으로 Floating-Point Literal은
double 타입으로 취급된다. (5.0 리터럴은 double이다.)
float임을 명시적으로 표현하려면 숫자 뒤에 F 또는 f를 붙인다.
double임을 명시적으로 표현하려면 숫자 뒤에 D 또는 d를 붙인다.
Scientific Notation
- Floating-Point Literals는 Scientific Notation으로 표현할 수 있다.
- 1.2345e+2, 1.2345e2와 같은 것을 Scientific Notation이라고 한다.
E 혹은 e를 붙여 지수를 나타내는 표현이다.
- (ex: 1.2345e+2 == 1.2345e2 == 1.2345E2 == 123.45)