
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_ttype는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 |