Skip to main content

F.1 Machine_Radix Attribute Definition Clause

danger

This Reference Manual output has not been verified, and may contain omissions or errors. Report any problems on the tracking issue

Static Semantics

1/5

The representation attribute Machine_Radix may be specified for a decimal first subtype (see 3.5.9) via an attribute_definition_clause; the expression of such a clause shall be static, and its value shall be 2 or 10. A value of 2 implies a binary base range; a value of 10 implies a decimal base range.

1.a
ramification

In the absence of a Machine_Radix clause, the choice of 2 versus 10 for S'Machine_Radix is not specified.

1.b/3

Aspect Description for Machine_Radix: Radix (2 or 10) that is used to represent a decimal fixed point type.

Implementation Advice

2

Packed decimal should be used as the internal representation for objects of subtype S when S'Machine_Radix = 10.

2.a/2
implementation advice

Packed decimal should be used as the internal representation for objects of subtype S when S'Machine_Radix = 10.

2.b/3
discussion

The intent of a decimal Machine_Radix attribute definition clause is to allow the programmer to declare an Ada decimal data object whose representation matches a particular COBOL implementation's representation of packed decimal items. The Ada object may then be passed to an interfaced COBOL program that takes a packed decimal data item as a parameter, assuming that convention COBOL has been specified for the Ada object's type with an aspect Convention.

2.c

Additionally, the Ada compiler may choose to generate arithmetic instructions that exploit the packed decimal representation.

Examples

3

Example of Machine_Radix attribute definition clause:

4

type Money is delta 0.01 digits 15; for Money'Machine_Radix use 10;

Wording Changes from Ada 2012

4.a/5

Clarified that Machine_Radix is a representation aspect.