conversion의 설계 개념
C++의 conversion를 정의할 때, 직교하는 3 요소, value category
, cv-qualification
, data representation
를 설계 개념으로 사용한다. conversion를 설계할 때, 요소 중 하나만을 변형하고, 다른 요소를 변형하지 않는다. 어떤 이유로, 예를 들어 하위 호환성을 위해, 설계 개념을 위반할 때는 관련된 특수 조항을 스펙 문서에 별도로 명시한다.
floating-point conversion rank
floating-point type T
가다른 floating-point type
의 value set를 진부분 집합으로 갖는다면, T가greater rank
하다.long double
는double
보다,dobule
는float
보다greater rank
하다.같은 value set
를 갖는두 extended floating-point type
는equal rank
하다.cv-unqualified standard floating-point type T
와 같은 value set를 갖는extended floating-point type
는 T와equal rank
하다.하나 이상의 cv-unqualified standard floating-point type
과 같은 value set를 갖는extended floating-point type
는double
과equal rank
하다.- 어느 한쪽의 value set이 다른 쪽읜 value set를 부분 집합으로 갖지 않는
floating-point type T1,T2
는unordered rank
하다. 예를 들어, 비교하는 두 타입 중 하나가larger range
이고, 동시에lower precision
일 때unordered rank
하다.
floating-point conversion subrank
equal rank
를 갖는 서로 다른floating-point type
는floating-point conversion subrank
로 정렬한다.equal rank
의floating-point conversion subrank
는total ordering
하다.std::float16_t
,std::float32_t
,std::float64_t
,std::float128_t
type는equal rank
를 갖고 있는standard floating-point type
보다greater subrank
하다. 다른 경우에는greater subrank
를 implementation-defined한 방법으로 선택한다.
floating-point conversions
data representation
요소를 변형하기 위해 설계한 conversion이다. data representation
를 변경하기 때문에, conversion rank
로 분류된다. 또한 일반적으로 value category
이나 cv-qualification
를 변경하지 않는다.
floating-point conversions
는 prvalue category
에서 prvalue category
로 변환을 정의한다.
floating-point type
의 prvalue category
는 greater or equal conversion rank
를 갖는 다른 floating-point type
의 prvalue category
로 변경할 수 있다. standard floating-point type
의 prvalue category
는 또다른 standard floaging-point type
의 prvalue category
로 변경할 수 있다.
source value
를 목적 타입의 정확한 값으로 표현할 수 있다면, conversion 결과는 목적 타입의 정확한 값이다. source value
가 목적 타입의 근접한 두 사이값이면, conversion 결과는 implementation-definition
으로 선택한 두 값 중 하나다. 그 외 경우는 undefined behavior다. 따라서 변환 과정에서 정밀도를 손실한다.
floating-point promotions conversion
를 floating-point conversions
에서 제외한다.
'프로그래밍 언어 > C++' 카테고리의 다른 글
pointer conversions에 대해 (0) | 2024.03.02 |
---|---|
floating-integral conversion에 대해 (0) | 2024.03.01 |
integral conversion에 대해 (0) | 2024.02.29 |
floating-point promotion conversion에 대해 (0) | 2024.02.28 |
integral promotion conversion에 대해 (0) | 2024.02.26 |