Ada Programming/Attributes/'Width
< Ada Programming < AttributesComputing » Computer Science » Computer Programming » Ada Programming

Description
X'Width is an Ada attribute where X is any discrete type. This attribute represents the number of characters it takes to represent the "longest" type value using the X'Image attribute.
Example
type My_Enum is (Big, Bigger, Biggest); ... pragma Assert (My_Enum'Image (Biggest) = "BIGGEST" ); pragma Assert (My_Enum'Width = 7); -- Width of "BIGGEST" is seven -- Width of "BIG" and "BIGGER" are irrelevant.
See also
Wikibook
Ada Reference Manual
- 13.3 Operational and Representation Attributes (Annotated)
- Annex K Language-Defined Attributes (Annotated)
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.