0% found this document useful (0 votes)
50 views1 page

Enumerated Type

1) An enumerated type is a data type consisting of a set of named values called enumerators that behave like constants. 2) For example, the four suits in a deck of cards (clubs, diamonds, hearts, spades) could be enumerators in a type called "suits". 3) Enumerated types are implemented as fixed-length bit strings compatible with integer types, and variables can be assigned any of the enumerator values.

Uploaded by

Atul Goel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views1 page

Enumerated Type

1) An enumerated type is a data type consisting of a set of named values called enumerators that behave like constants. 2) For example, the four suits in a deck of cards (clubs, diamonds, hearts, spades) could be enumerators in a type called "suits". 3) Enumerated types are implemented as fixed-length bit strings compatible with integer types, and variables can be assigned any of the enumerator values.

Uploaded by

Atul Goel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Enumerated type

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computer programming, an enumerated type (also called enumeration or enum) is a


data type consisting of a set of named values called elements, members or enumerators
of the type. The enumerator names are usually identifiers that behave as constants in the
language. A variable that has been declared as having an enumerated type can be
assigned any of the enumerators as a value.

For example, the four suits in a deck of playing cards may be four enumerators named
CLUB, DIAMOND, HEART, SPADE, belonging to an enumerated type named suits. If a
variable V is declared having suits as its data type, one can assign any of those four
values to it.

The enumerators are necessarily distinct, even though some languages may allow the
same enumerator to be listed twice in the type's declaration. The enumerators need not be
complete or compatible in any sense. For example, an enumerated type called color may
be defined to consist of the enumerators RED, GREEN, ZEBRA, and MISSING. In some
languages, the declaration of an enumerated type also defines an ordering of its members.

Some enumerator types may be built into the language. The Boolean type, for example is
often a pre-defined enumeration of the values FALSE and TRUE. Many languages allow
the user to define new enumerated types.

Values and variables of an enumerated type are usually implemented as fixed-length bit
strings, often in a format and size compatible with some integer type. Some languages,
especially system programming languages, allow the user to specify the bit combination
to be used for each enumerator. In type theory, enumerated types are often regarded as
tagged unions of unit types. Since such types are of the form 1 + 1 + ... + 1, they may also
be written as natural numbers

You might also like