- Title
- Bits required for negative enumerator values
- Status
- cd5
- Section
- 9.7.1 [dcl.enum]
- Submitter
- Hyman Rosen

Created on **2013-03-07.00:00:00**
last changed **20 months ago**

Date: 2018-06-15.00:00:00

**Proposed resolution (June, 2018):**

Change 9.7.1 [dcl.enum] paragraph 8 as follows:

b_{max}is the smallest value greater than or equal tomax(|e_{min}| -K~~, |~~,e_{max}|)e_{max}) and equal to 2^{M}- 1, whereMis a non-negative integer.

Date: 2018-11-15.00:00:00

[Accepted as a DR at the November, 2018 (San Diego) meeting.]

According to 9.7.1 [dcl.enum] paragraph 7,

For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type. Otherwise, for an enumeration whereeis the smallest enumerator and_{min}eis the largest, the values of the enumeration are the values in the range_{max}bto_{min}b, defined as follows: Let_{max}Kbe 1 for a two's complement representation and 0 for a one's complement or sign-magnitude representation.bis the smallest value greater than or equal to max(|_{max}e|-_{min}K,|e|) and equal to 2_{max}-1, where^{M}Mis a non-negative integer.bis zero if_{min}eis non-negative and -(_{min}b+_{max}K) otherwise. The size of the smallest bit-field large enough to hold all the values of the enumeration type is max(M,1) ifbis zero and_{min}M+1 otherwise.

The result of these calculations is that the number of bits required for

enum { N = -1, Z = 0 }

is 1, but the number required for

enum { N = -1 }

is 2. This is surprising. This could be fixed by changing
|*e _{max}*| to

History | |||
---|---|---|---|

Date | User | Action | Args |

2020-12-15 00:00:00 | admin | set | messages: + msg6399 |

2020-12-15 00:00:00 | admin | set | status: drafting -> cd5 |

2013-05-03 00:00:00 | admin | set | status: open -> drafting |

2013-03-07 00:00:00 | admin | create |