Kotlin - 숫자타입(Number Type), Inheritors, 언더바(Underscore) 삽입

CODEDRAGON Development/Kotlin

반응형


 

 

숫자타입(Number Type)

·         Int, Double, Float, Long, Short, Byte 타입을 제공합니다.

·         Int, Double, Float, Long, Short, Byte 클래스이며 타입을 명시하여 선언한 변수는 그자체로 객체(object)입니다.

·         자동형변형(implicit conversions for number)을제공하지않는다.

·         숫자타입에서 8진수를 지원하지 않습니다.

 

Type

Bit Width

Double

64

Float

32

Long

64

Int

32

Short

16

Byte

8

 

 

 

http://bit.ly/2yJ4typ


 

 

Inheritors

숫자타입의 클래스들은 모두 Number 타입의 서브클래스 입니다.

Byte

class Byte : NumberComparable<Byte>

Represents a 8-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type byte.

Double

class Double : NumberComparable<Double>

Represents a double-precision 64-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type double.

Float

class Float : NumberComparable<Float>

Represents a single-precision 32-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type float.

Int

class Int : NumberComparable<Int>

Represents a 32-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type int.

Long

class Long : NumberComparable<Long>

Represents a 64-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type long.

Short

class Short : NumberComparable<Short>

Represents a 16-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type short.

http://bit.ly/2DWdPwD

 

 

 

 

언더바(Underscore) 삽입

숫자타입으로 대입되는 데이터에 언더바(Underscore) 중간에 삽입할 있습니다.

val oneMillion: Int = 1_000_000

println(oneMillion)

// 1000000