| 1 |
@Part(realattribs, Root="ada.mss") |
| 2 |
|
| 3 |
@Comment{$Date: 2019/02/09 03:46:56 $} |
| 4 |
|
| 5 |
@comment{$Source: e:\\cvsroot/ARM/Source/real_attribs.mss,v $} |
| 6 |
@comment{$Revision: 1.28 $} |
| 7 |
|
| 8 |
@LabeledSubClause{Attributes of Floating Point Types} |
| 9 |
|
| 10 |
@begin{StaticSem} |
| 11 |
@Leading@Defn2{Term=[representation-oriented attributes], |
| 12 |
Sec=[of a floating point subtype]} |
| 13 |
The following @i{representation-oriented attributes} are defined for |
| 14 |
@PrefixType{every subtype S of a floating point type @i{T}}. |
| 15 |
@begin{Description} |
| 16 |
@Attribute{Prefix=<S>, AttrName=<Machine_Radix>, |
| 17 |
Text=[Yields the radix of the hardware |
| 18 |
representation of the type @i{T}. The value of this attribute is of |
| 19 |
the type @i{universal_integer}.]} |
| 20 |
@end{Description} |
| 21 |
|
| 22 |
@Defn{canonical form} |
| 23 |
The values of other representation-oriented attributes of a floating point |
| 24 |
subtype, and of the @lquotes@;primitive function@rquotes@; attributes of a floating point |
| 25 |
subtype described later, are defined in terms of a particular representation |
| 26 |
of nonzero values called the @i{canonical form}. |
| 27 |
The canonical form (for the type @i{T}) is the form@* |
| 28 |
@ @ @ @ @PorM @RI{mantissa} @Times @RI{T}@R['Machine_Radix]@+{@RI{exponent}}@* |
| 29 |
where |
| 30 |
@begin{Itemize} |
| 31 |
@i{mantissa} is a fraction in the number base @i{T}'Machine_Radix, |
| 32 |
the first digit of which is nonzero, and |
| 33 |
|
| 34 |
@i{exponent} is an integer. |
| 35 |
@end{Itemize} |
| 36 |
@begin{Description} |
| 37 |
@Attribute{Prefix=<S>, AttrName=<Machine_Mantissa>, |
| 38 |
Text=[Yields the largest value of @RI{p} such that every value expressible |
| 39 |
in the canonical form (for the type @i{T}), having a @RI{p}-digit |
| 40 |
@i{mantissa} and an @i{exponent} between @i{T}'Machine_Emin and |
| 41 |
@i{T}'Machine_Emax, is a machine number (see @RefSecNum{Floating Point Types}) |
| 42 |
of the type @i{T}. This attribute yields a value of the type |
| 43 |
@i{universal_integer}.]} |
| 44 |
@begin{Ramification} |
| 45 |
Values of a type held in an extended register are, in general, not machine |
| 46 |
numbers of the type, since they cannot be expressed in the canonical form |
| 47 |
with a sufficiently short @i{mantissa}. |
| 48 |
@end{Ramification} |
| 49 |
|
| 50 |
@Attribute{Prefix=<S>, AttrName=<Machine_Emin>, |
| 51 |
Text=[Yields the smallest (most negative) value of @i{exponent} such |
| 52 |
that every value expressible in the canonical form (for the type @i{T}), |
| 53 |
having a @i{mantissa} of @i{T}'Machine_Mantissa digits, is a machine number |
| 54 |
(see @RefSecNum{Floating Point Types}) of the type |
| 55 |
@i{T}. |
| 56 |
This attribute yields |
| 57 |
a value of the type @i{universal_integer}.]} |
| 58 |
|
| 59 |
@Attribute{Prefix=<S>, AttrName=<Machine_Emax>, |
| 60 |
Text=[Yields the largest (most positive) value of @i{exponent} such that |
| 61 |
every value expressible in the canonical form (for the type @i{T}), having |
| 62 |
a @i{mantissa} of @i{T}'Machine_Mantissa digits, is a machine number |
| 63 |
(see @RefSecNum{Floating Point Types}) of the type @i{T}. This attribute |
| 64 |
yields a value of the type @i{universal_integer}.]} |
| 65 |
@begin{Ramification} |
| 66 |
|
| 67 |
Note that the above definitions do not determine unique values for the |
| 68 |
representation-oriented attributes of floating point types. |
| 69 |
The implementation may choose any set of values that collectively |
| 70 |
satisfies the definitions. |
| 71 |
|
| 72 |
@end{Ramification} |
| 73 |
|
| 74 |
@Attribute{Prefix=<S>, AttrName=<Denorm>, |
| 75 |
Text=[Yields the value True if every value expressible in the form@* |
| 76 |
@ @ @ @ @PorM @RI{mantissa} @Times @RI{T}@R{'Machine_Radix}@+{@RI{T}@R{'Machine_Emin}}@* |
| 77 |
where @i{mantissa} is a nonzero @i{T}'Machine_Mantissa-digit fraction in the |
| 78 |
number base @i{T}'Machine_Radix, the first digit of which is zero, |
| 79 |
is a machine number (see @RefSecNum{Floating Point Types}) of the type |
| 80 |
@i{T}; yields the value False otherwise. |
| 81 |
The value |
| 82 |
of this attribute is of the predefined type Boolean.]} |
| 83 |
@end{Description} |
| 84 |
|
| 85 |
@Defn{denormalized number} |
| 86 |
The values described by the formula in the definition of S'Denorm are called |
| 87 |
@i{denormalized numbers}. |
| 88 |
@Defn{normalized number} |
| 89 |
A nonzero machine number that is not a denormalized number is a |
| 90 |
@i{normalized number}. |
| 91 |
@Defn{represented in canonical form} |
| 92 |
@Defn{canonical-form representation} |
| 93 |
A normalized number @RI{x} of a given type @i{T} is said to be |
| 94 |
@i{represented in canonical form} when it is expressed in the |
| 95 |
canonical form (for the type @i{T}) with a @i{mantissa} |
| 96 |
having @i{T}'Machine_Mantissa digits; |
| 97 |
the resulting form is the @i{canonical-form representation} of @RI{x}. |
| 98 |
@begin{Discussion} |
| 99 |
The intent is that S'Denorm be True when such denormalized numbers exist |
| 100 |
and are generated in the circumstances defined by IEC 559:1989, |
| 101 |
though the latter requirement is not formalized here. |
| 102 |
@end{Discussion} |
| 103 |
@begin{Description} |
| 104 |
@Attribute{Prefix=<S>, AttrName=<Machine_Rounds>, |
| 105 |
Text=[Yields the value True if rounding is performed on inexact |
| 106 |
results of every predefined operation that yields a result of the |
| 107 |
type @i{T}; yields the value False otherwise. |
| 108 |
The value |
| 109 |
of this attribute is of the predefined type Boolean.]} |
| 110 |
@begin{Discussion} |
| 111 |
@Leading@;It is difficult to be more precise about what it means to round |
| 112 |
the result of a predefined operation. If the implementation does not use |
| 113 |
extended registers, so that every arithmetic result is necessarily a machine |
| 114 |
number, then rounding seems to imply two things: |
| 115 |
@begin{Itemize} |
| 116 |
S'Model_Mantissa = S'Machine_Mantissa, so that operand preperturbation |
| 117 |
never occurs; |
| 118 |
|
| 119 |
when the exact mathematical result is not a machine number, the result of |
| 120 |
a predefined operation must be the nearer of the two adjacent machine |
| 121 |
numbers. |
| 122 |
@end{Itemize} |
| 123 |
|
| 124 |
Technically, this attribute should yield False when extended registers are |
| 125 |
used, since a few computed results will cross over the half-way point as |
| 126 |
a result of double rounding, if and when a value held in an extended |
| 127 |
register has to be reduced in precision to that of the machine numbers. It |
| 128 |
does not seem desirable to preclude the use of extended registers when |
| 129 |
S'Machine_Rounds could otherwise be True. |
| 130 |
@end{Discussion} |
| 131 |
|
| 132 |
@Attribute{Prefix=<S>, AttrName=<Machine_Overflows>, |
| 133 |
Text=[Yields the value True if overflow and |
| 134 |
divide-by-zero are detected and |
| 135 |
reported by raising Constraint_Error for every predefined operation that |
| 136 |
yields a result of the type @i{T}; |
| 137 |
yields the value False otherwise. |
| 138 |
The value of this |
| 139 |
attribute is of the predefined type Boolean.]} |
| 140 |
|
| 141 |
@Attribute{Prefix=<S>, AttrName=<Signed_Zeros>, |
| 142 |
Text=[Yields the value True if the hardware representation for the |
| 143 |
type @i{T} has the capability of representing both positively and negatively |
| 144 |
signed zeros, these being generated and used by the predefined operations of |
| 145 |
the type @i{T} as specified in IEC 559:1989; yields the value False |
| 146 |
otherwise. |
| 147 |
The value of this attribute |
| 148 |
is of the predefined type Boolean.]} |
| 149 |
@end{Description} |
| 150 |
|
| 151 |
@Leading@Defn{normalized exponent} |
| 152 |
For every value @RI{x} of a floating point type @i{T}, the |
| 153 |
@i{normalized exponent} of @RI{x} is defined as follows: |
| 154 |
@begin{Itemize} |
| 155 |
the normalized exponent of zero is (by convention) zero; |
| 156 |
|
| 157 |
for nonzero @RI{x}, the normalized exponent of @RI{x} is the unique |
| 158 |
integer @RI{k} such that |
| 159 |
@RI{T}@R['Machine_Radix]@+{@RI{k}@en@;1} @leq @Abs{@RI{x}} @Lt |
| 160 |
@RI{T}@R['Machine_Radix]@+{@RI{k}}. |
| 161 |
@end{Itemize} |
| 162 |
@begin{Ramification} |
| 163 |
The normalized exponent of a normalized number @RI{x} is the value |
| 164 |
of @i{exponent} in the canonical-form representation of @RI{x}. |
| 165 |
|
| 166 |
The normalized exponent of a denormalized number is less than the value of |
| 167 |
@i{T}'Machine_Emin. |
| 168 |
@end{Ramification} |
| 169 |
|
| 170 |
@begin{WideAbove} |
| 171 |
@Leading@Defn{primitive function} |
| 172 |
The following @i{primitive function attributes} are defined for any subtype |
| 173 |
S of a floating point type @i{T}. |
| 174 |
@end{WideAbove} |
| 175 |
@begin(Description) |
| 176 |
@AttributeLeading{Prefix=<S>, AttrName=<Exponent>, |
| 177 |
Text=[S'Exponent denotes a function with the following |
| 178 |
specification: |
| 179 |
@begin(DescExample) |
| 180 |
@key(function) S'Exponent (@RI(X) : @RI(T)) |
| 181 |
@key(return) @RI(universal_integer) |
| 182 |
@end(DescExample) |
| 183 |
|
| 184 |
@NoPrefix@;The function yields the normalized exponent of @i{X}.]} |
| 185 |
|
| 186 |
@AttributeLeading{Prefix=<S>, AttrName=<Fraction>, |
| 187 |
Text=[S'Fraction denotes a function with the following |
| 188 |
specification: |
| 189 |
@begin(DescExample) |
| 190 |
@key(function) S'Fraction (@RI(X) : @RI(T)) |
| 191 |
@key(return) @RI(T) |
| 192 |
@end(DescExample) |
| 193 |
|
| 194 |
@NoPrefix@;The function yields the value @RI(X) @Times @RI(T)@R('Machine_Radix)@+(@en@RI(k)), where |
| 195 |
@RI(k) is the normalized exponent of @i(X). A zero result@Redundant(, which |
| 196 |
can only occur when @i(X) is zero,) has the sign of @i(X).]} |
| 197 |
@begin{Discussion} |
| 198 |
Informally, when @i{X} is a normalized number, the result is the value |
| 199 |
obtained by replacing the @i{exponent} by zero in the canonical-form |
| 200 |
representation of @i{X}. |
| 201 |
@end{Discussion} |
| 202 |
@begin{Ramification} |
| 203 |
Except when @i{X} is zero, the magnitude of the result is |
| 204 |
greater than or equal to the reciprocal of @i{T}'Machine_Radix and less than |
| 205 |
one; consequently, the result is always a normalized number, even when @i{X} |
| 206 |
is a denormalized number. |
| 207 |
@end{Ramification} |
| 208 |
@begin{ImplNote} |
| 209 |
When @i{X} is a denormalized number, the result is the value obtained by |
| 210 |
replacing the @i{exponent} by zero in the canonical-form representation of |
| 211 |
the result of scaling @i{X} up sufficiently to normalize it. |
| 212 |
@end{ImplNote} |
| 213 |
|
| 214 |
@AttributeLeading{Prefix=<S>, AttrName=<Compose>, |
| 215 |
Text=[S'Compose denotes a function with the following |
| 216 |
specification: |
| 217 |
@begin{DescExample} |
| 218 |
@key(function) S'Compose (@RI{Fraction} : @RI{T}; |
| 219 |
@RI{Exponent} : @RI{universal_integer}) |
| 220 |
@key(return) @RI{T} |
| 221 |
@end{DescExample} |
| 222 |
|
| 223 |
@NoPrefix@;@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 224 |
Let @RI{v} be the value @RI{Fraction} @Times |
| 225 |
@RI{T}@R('Machine_Radix)@+{@RI{Exponent}@en@RI{k}}, |
| 226 |
where @RI{k} is the normalized exponent of @i{Fraction}. |
| 227 |
If @RI{v} is a machine number of the type @i{T}, or if |
| 228 |
@Abs{@RI{v}} @geq @RI{T}@R('Model_Small), the function yields @RI{v}; |
| 229 |
otherwise, |
| 230 |
it yields either one of the machine numbers of the type @i{T} adjacent to |
| 231 |
@RI{v}. |
| 232 |
@IndexCheck{Range_Check}Constraint_Error is optionally raised if |
| 233 |
@RI{v} is outside the base range of S. |
| 234 |
A zero result has the sign of @i{Fraction} when S'Signed_Zeros is True.]} |
| 235 |
@begin{Discussion} |
| 236 |
Informally, when @i{Fraction} and @RI{v} are both normalized numbers, the |
| 237 |
result is the value obtained by replacing the @i{exponent} by @i{Exponent} |
| 238 |
in the canonical-form representation of @i{Fraction}. |
| 239 |
@end{Discussion} |
| 240 |
@begin{Ramification} |
| 241 |
If @i{Exponent} is less than @i{T}'Machine_Emin and |
| 242 |
@i{Fraction} is nonzero, the result is either zero, @i{T}'Model_Small, or |
| 243 |
(if @i{T}'Denorm is True) a denormalized number. |
| 244 |
@end{Ramification} |
| 245 |
|
| 246 |
@AttributeLeading{Prefix=<S>, AttrName=<Scaling>, |
| 247 |
Text=[S'Scaling denotes a function with the following |
| 248 |
specification: |
| 249 |
@begin{DescExample} |
| 250 |
@key(function) S'Scaling (@RI{X} : @RI{T}; |
| 251 |
@RI{Adjustment} : @RI{universal_integer}) |
| 252 |
@key(return) @RI{T} |
| 253 |
@end{DescExample} |
| 254 |
|
| 255 |
@NoPrefix@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 256 |
Let @RI{v} be the value @RI{X} @Times @RI{T}@R('Machine_Radix)@+{@RI{Adjustment}}. |
| 257 |
If @RI{v} is a machine number of the type @i{T}, or if |
| 258 |
@Abs{@RI{v}} @geq @RI{T}@R('Model_Small), the function yields @RI{v}; |
| 259 |
otherwise, |
| 260 |
it yields either one of the machine numbers of the type @i{T} adjacent to |
| 261 |
@RI{v}. |
| 262 |
@IndexCheck{Range_Check}Constraint_Error is optionally raised if |
| 263 |
@RI{v} is outside the base range of S. |
| 264 |
A zero result has the sign of @i{X} when S'Signed_Zeros is True.]} |
| 265 |
@begin{Discussion} |
| 266 |
Informally, when @i{X} and @RI{v} are both normalized numbers, the result |
| 267 |
is the value obtained by increasing the @i{exponent} by @i{Adjustment} in the |
| 268 |
canonical-form representation of @i{X}. |
| 269 |
@end{Discussion} |
| 270 |
@begin{Ramification} |
| 271 |
If @i{Adjustment} is sufficiently small (i.e., sufficiently negative), the |
| 272 |
result is |
| 273 |
either zero, @i{T}'Model_Small, or (if @i{T}'Denorm is True) a denormalized |
| 274 |
number. |
| 275 |
@end{Ramification} |
| 276 |
|
| 277 |
@AttributeLeading{Prefix=<S>, AttrName=<Floor>, |
| 278 |
Text=[S'Floor denotes a function with the following |
| 279 |
specification: |
| 280 |
@begin{DescExample} |
| 281 |
@key(function) S'Floor (@RI{X} : @RI{T}) |
| 282 |
@key(return) @RI{T} |
| 283 |
@end{DescExample} |
| 284 |
|
| 285 |
@NoPrefix@;The function yields the value @Floor{@RI{X}}, |
| 286 |
i.e., the largest (most positive) integral value less than or equal to |
| 287 |
@i{X}. |
| 288 |
When @i{X} is zero, the |
| 289 |
result has the sign of @i{X}; a zero result otherwise has a positive |
| 290 |
sign.]} |
| 291 |
|
| 292 |
@AttributeLeading{Prefix=<S>, AttrName=<Ceiling>, |
| 293 |
Text=[S'Ceiling denotes a function with the following |
| 294 |
specification: |
| 295 |
@begin{DescExample} |
| 296 |
@key(function) S'Ceiling (@RI{X} : @RI{T}) |
| 297 |
@key(return) @RI{T} |
| 298 |
@end{DescExample} |
| 299 |
|
| 300 |
@NoPrefix@;The function yields the value @Ceiling{@RI{X}}, |
| 301 |
i.e., the smallest (most negative) integral value greater than or equal to |
| 302 |
@i{X}. |
| 303 |
When @i{X} is zero, the |
| 304 |
result has the sign of @i{X}; a zero result otherwise has a negative sign |
| 305 |
when S'Signed_Zeros is True.]} |
| 306 |
|
| 307 |
@AttributeLeading{Prefix=<S>, AttrName=<Rounding>, |
| 308 |
Text=[S'Rounding denotes a function with the following |
| 309 |
specification: |
| 310 |
@begin{DescExample} |
| 311 |
@key(function) S'Rounding (@RI{X} : @RI{T}) |
| 312 |
@key(return) @RI{T} |
| 313 |
@end{DescExample} |
| 314 |
|
| 315 |
@NoPrefix@;The function yields the integral value nearest to @i{X}, |
| 316 |
rounding away from zero if @i{X} lies exactly halfway between two integers. |
| 317 |
A zero result has the sign of @i{X} when S'Signed_Zeros is True.]} |
| 318 |
|
| 319 |
@AttributeLeading{Prefix=<S>, AttrName=<Unbiased_Rounding>, |
| 320 |
Text=[S'Unbiased_Rounding denotes a function with |
| 321 |
the following specification: |
| 322 |
@begin{DescExample} |
| 323 |
@key(function) S'Unbiased_Rounding (@RI{X} : @RI{T}) |
| 324 |
@key(return) @RI{T} |
| 325 |
@end{DescExample} |
| 326 |
|
| 327 |
@NoPrefix@;The function yields the integral value nearest to @i{X}, |
| 328 |
rounding toward the even integer if @i{X} lies exactly halfway between |
| 329 |
two integers. A zero result has the sign of @i{X} when S'Signed_Zeros is |
| 330 |
True.]} |
| 331 |
|
| 332 |
@ChgAttribute{Version=[2],Kind=[Added],ChginAnnex=[T], |
| 333 |
Leading=<T>, Prefix=<S>, AttrName=<Machine_Rounding>, ARef=[AI95-00267-01], |
| 334 |
Text=[@Chg{Version=[2],New=[S'Machine_Rounding denotes a function |
| 335 |
with the following specification:],Old=[]} |
| 336 |
@begin(Descexample) |
| 337 |
@ChgRef{Version=[2],Kind=[Added]} |
| 338 |
@ChgAdded{Version=[2],Text=[@key(function) S'Machine_Rounding (@RI{X} : @RI{T}) |
| 339 |
@key(return) @RI{T}]} |
| 340 |
@end(Descexample) |
| 341 |
|
| 342 |
@ChgRef{Version=[2],Kind=[Added]} |
| 343 |
@ChgAdded{Version=[2],NoPrefix=[T],Text=[The function yields the |
| 344 |
integral value nearest to @i{X}. If @i{X} lies exactly halfway between two |
| 345 |
integers, one of those integers is returned, but which of them is returned |
| 346 |
is unspecified. A zero result has the sign of @i{X} when S'Signed_Zeros is |
| 347 |
True. This function provides access to the rounding behavior which is most |
| 348 |
efficient on the target processor.@PDefn{unspecified}]}]} |
| 349 |
|
| 350 |
@begin{Discussion} |
| 351 |
@ChgRef{Version=[2],Kind=[Added]} |
| 352 |
@ChgAdded{Version=[2],Text=[We leave the rounding unspecified, so that |
| 353 |
users cannot depend on a particular rounding. This attribute is intended |
| 354 |
for use in cases where the particular rounding chosen is irrelevant. If |
| 355 |
there is a need to know which way values halfway between two integers are |
| 356 |
rounded, one of the other rounding attributes should be used.]} |
| 357 |
@end{Discussion} |
| 358 |
|
| 359 |
@AttributeLeading{Prefix=<S>, AttrName=<Truncation>, |
| 360 |
Text=[S'Truncation denotes a function with the following |
| 361 |
specification: |
| 362 |
@begin{DescExample} |
| 363 |
@key(function) S'Truncation (@RI{X} : @RI{T}) |
| 364 |
@key(return) @RI{T} |
| 365 |
@end{DescExample} |
| 366 |
|
| 367 |
@NoPrefix@;The function yields the value @Ceiling{@RI{X}} when @i{X} is negative, |
| 368 |
and @Floor{@RI{X}} otherwise. A zero result has the sign of @i{X} when |
| 369 |
S'Signed_Zeros is True.]} |
| 370 |
|
| 371 |
@AttributeLeading{Prefix=<S>, AttrName=<Remainder>, |
| 372 |
Text=[S'Remainder denotes a function with the following |
| 373 |
specification: |
| 374 |
@begin{DescExample} |
| 375 |
@key(function) S'Remainder (@RI{X}, @RI{Y} : @RI{T}) |
| 376 |
@key(return) @RI{T} |
| 377 |
@end{DescExample} |
| 378 |
|
| 379 |
@NoPrefix@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 380 |
For nonzero @i{Y}, let @RI{v} be the value |
| 381 |
@RI{X} @en @RI{n} @Times @RI{Y}, where @RI{n} is the integer nearest to |
| 382 |
the exact value of @RI{X}/@RI{Y}; if @Abs{@RI{n} @en @RI{X}/@RI{Y}} = 1/2, |
| 383 |
then @RI(n) is chosen to be even. If @RI{v} is a machine number of |
| 384 |
the type @i{T}, the function yields @RI{v}; otherwise, it yields zero. |
| 385 |
@IndexCheck{Division_Check}Constraint_Error is raised if @i{Y} is zero. |
| 386 |
A zero result has the sign of @i{X} when S'Signed_Zeros is True.]} |
| 387 |
@begin{Ramification} |
| 388 |
The magnitude of the result is less than or equal to one-half the magnitude |
| 389 |
of @i{Y}. |
| 390 |
@end{Ramification} |
| 391 |
@begin{Discussion} |
| 392 |
Given machine numbers @i{X} and @i{Y} of the type @i{T}, @RI{v} is |
| 393 |
necessarily a machine number of the type @i{T}, except when @i{Y} is in the |
| 394 |
neighborhood of zero, @i{X} is sufficiently close to a multiple of @i{Y}, |
| 395 |
and @i{T}'Denorm is False. |
| 396 |
@end{Discussion} |
| 397 |
|
| 398 |
@AttributeLeading{Prefix=<S>, AttrName=<Adjacent>, |
| 399 |
Text=[S'Adjacent denotes a function with the following |
| 400 |
specification: |
| 401 |
@begin{DescExample} |
| 402 |
@key(function) S'Adjacent (@RI{X}, @RI{Towards} : @RI{T}) |
| 403 |
@key(return) @RI{T} |
| 404 |
@end{DescExample} |
| 405 |
|
| 406 |
@NoPrefix@;@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 407 |
If @RI{Towards} = @RI{X}, the function yields @i{X}; otherwise, it |
| 408 |
yields the machine number of the type @i{T} adjacent to @i{X} in the |
| 409 |
direction of @i{Towards}, if that machine number exists. |
| 410 |
@IndexCheck{Range_Check}If the result would |
| 411 |
be outside the base range of S, Constraint_Error is raised. |
| 412 |
When @i{T}'Signed_Zeros is True, a zero result has the sign of @i{X}. |
| 413 |
When @i{Towards} is zero, its sign has no bearing on the result.]} |
| 414 |
@begin{Ramification} |
| 415 |
The value of S'Adjacent(0.0, 1.0) is the smallest normalized positive number |
| 416 |
of the type @i{T} when @i{T}'Denorm is False and the smallest denormalized |
| 417 |
positive number of the type @i{T} when @i{T}'Denorm is True. |
| 418 |
@end{Ramification} |
| 419 |
|
| 420 |
@AttributeLeading{Prefix=<S>, AttrName=<Copy_Sign>, |
| 421 |
Text=[S'Copy_Sign denotes a function with the following specification: |
| 422 |
@begin{DescExample} |
| 423 |
@key(function) S'Copy_Sign (@RI{Value}, @RI{Sign} : @RI{T}) |
| 424 |
@key(return) @RI{T} |
| 425 |
@end{DescExample} |
| 426 |
|
| 427 |
@NoPrefix@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 428 |
If the value of @i{Value} is nonzero, the function yields a result whose |
| 429 |
magnitude is that of @i{Value} and whose sign is that of @i{Sign}; |
| 430 |
otherwise, it yields the value zero. |
| 431 |
@IndexCheck{Range_Check}Constraint_Error is optionally raised if the result |
| 432 |
is outside the base range of S. |
| 433 |
A zero result has the sign of @i{Sign} when S'Signed_Zeros is True.]} |
| 434 |
@begin{Discussion} |
| 435 |
S'Copy_Sign is provided for convenience in restoring the sign to a quantity |
| 436 |
from which it has been temporarily removed, or to a related quantity. When |
| 437 |
S'Signed_Zeros is True, it is also instrumental in determining the sign |
| 438 |
of a zero quantity, when required. (Because negative and positive zeros |
| 439 |
compare equal in systems conforming to IEC 559:1989, a negative zero does |
| 440 |
@i{not} appear to be negative when compared to zero.) The sign |
| 441 |
determination is accomplished by transferring the sign of the zero quantity |
| 442 |
to a nonzero quantity and then testing for a negative result. |
| 443 |
@end{Discussion} |
| 444 |
|
| 445 |
@AttributeLeading{Prefix=<S>, AttrName=<Leading_Part>, |
| 446 |
Text=[S'Leading_Part denotes a function with the following specification: |
| 447 |
@begin{DescExample} |
| 448 |
@key(function) S'Leading_Part (@RI{X} : @RI{T}; |
| 449 |
@RI{Radix_Digits} : @RI{universal_integer}) |
| 450 |
@key(return) @RI{T} |
| 451 |
@end{DescExample} |
| 452 |
|
| 453 |
@NoPrefix@;Let @RI{v} be the value @RI{T}@R('Machine_Radix)@+{@RI{k}@en@RI{Radix_Digits}}, |
| 454 |
where @RI{k} is the normalized exponent of @i{X}. The function yields |
| 455 |
the value |
| 456 |
@begin{Itemize} |
| 457 |
@Floor{@RI{X}/@RI{v}} @Times @RI{v}, |
| 458 |
when @i{X} is nonnegative and @i{Radix_Digits} is positive; |
| 459 |
|
| 460 |
@Ceiling{@RI{X}/@RI{v}} @Times @RI{v}, |
| 461 |
when @i{X} is negative and @i{Radix_Digits} is positive. |
| 462 |
@end{Itemize} |
| 463 |
|
| 464 |
@NoPrefix@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 465 |
@IndexCheck{Range_Check}Constraint_Error is raised when @i{Radix_Digits} |
| 466 |
is zero or negative. |
| 467 |
A zero result@Redundant{, which can only occur when @i{X} is zero,} has the |
| 468 |
sign of @i{X}.]} |
| 469 |
@begin{Discussion} |
| 470 |
Informally, if @i{X} is nonzero, the result is the value |
| 471 |
obtained by retaining only the specified number of (leading) significant |
| 472 |
digits of @i{X} (in the machine radix), setting all other digits to zero. |
| 473 |
@end{Discussion} |
| 474 |
@begin{ImplNote} |
| 475 |
The result can be obtained by first scaling @i{X} up, if necessary to |
| 476 |
normalize it, then masking the mantissa so as to retain only the specified |
| 477 |
number of leading digits, then scaling the result back down if @i{X} was |
| 478 |
scaled up. |
| 479 |
@end{ImplNote} |
| 480 |
|
| 481 |
@AttributeLeading{Prefix=<S>, AttrName=<Machine>, |
| 482 |
Text=[S'Machine denotes a function with the following specification: |
| 483 |
@begin{DescExample} |
| 484 |
@key(function) S'Machine (@RI{X} : @RI{T}) |
| 485 |
@key(return) @RI{T} |
| 486 |
@end{DescExample} |
| 487 |
|
| 488 |
@NoPrefix@Defn2{Term=(Constraint_Error),Sec=(raised by failure of runtime check)} |
| 489 |
If @i{X} is a machine number of the type @i{T}, the function yields @i{X}; |
| 490 |
otherwise, it yields the value obtained by rounding or truncating @i{X} to |
| 491 |
either one of the adjacent machine numbers of the type @i(T). |
| 492 |
@IndexCheck{Range_Check}Constraint_Error is raised if rounding or |
| 493 |
truncating @i{X} to the precision |
| 494 |
of the machine numbers results in a value outside the base range of S. |
| 495 |
A zero result has the sign of @i{X} when S'Signed_Zeros is True.]} |
| 496 |
@begin{Discussion} |
| 497 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]} |
| 498 |
All of the primitive function attributes except Rounding and Machine |
| 499 |
correspond to subprograms in the Generic_Primitive_Functions |
| 500 |
generic package @Chg{Version=[3],New=[that was ],Old=[]}proposed |
| 501 |
as a separate ISO standard (ISO/IEC DIS 11729) for |
| 502 |
Ada 83. The Scaling, Unbiased_Rounding, and Truncation attributes |
| 503 |
correspond to the Scale, Round, and Truncate functions, respectively, in |
| 504 |
Generic_Primitive_Functions. The Rounding attribute rounds away from zero; |
| 505 |
this functionality was not provided in Generic_Primitive_Functions. The |
| 506 |
name Round was not available for either of the primitive function attributes |
| 507 |
that perform rounding, since an attribute of that name is used for a |
| 508 |
different purpose for decimal fixed point types. Likewise, the name Scale |
| 509 |
was not available, since an attribute of that name is also used for a |
| 510 |
different purpose for decimal fixed point types. The functionality of the |
| 511 |
Machine attribute was also not provided in Generic_Primitive_Functions. The |
| 512 |
functionality of the Decompose procedure of Generic_Primitive_Functions is |
| 513 |
only provided in the form of the separate attributes Exponent and Fraction. |
| 514 |
The functionality of the Successor and Predecessor functions of |
| 515 |
Generic_Primitive_Functions is provided by the extension of the existing |
| 516 |
Succ and Pred attributes. |
| 517 |
@end{Discussion} |
| 518 |
@begin{ImplNote} |
| 519 |
The primitive function attributes may be implemented either with appropriate |
| 520 |
floating point arithmetic operations or with integer and logical operations |
| 521 |
that act on parts of the representation directly. The latter is strongly |
| 522 |
encouraged when it is more efficient than the former; it is mandatory when |
| 523 |
the former cannot deliver the required accuracy due to limitations of the |
| 524 |
implementation's arithmetic operations. |
| 525 |
@end{ImplNote} |
| 526 |
@end(Description) |
| 527 |
|
| 528 |
@begin{WideAbove} |
| 529 |
@Leading@Defn2{Term=[model-oriented attributes], |
| 530 |
Sec=[of a floating point subtype]} |
| 531 |
The following @i{model-oriented attributes} are defined for any subtype S of |
| 532 |
a floating point type @i{T}. |
| 533 |
@end{WideAbove} |
| 534 |
@begin{Description} |
| 535 |
@Attribute{Prefix=<S>, AttrName=<Model_Mantissa>, |
| 536 |
Text=[If the Numerics Annex is not supported, |
| 537 |
this attribute yields an implementation defined value that is |
| 538 |
greater than or equal to |
| 539 |
@Ceiling{@RI{d} @Times @Log(10) / @Log(@RI{T}'@R{Machine_Radix})} + 1, where |
| 540 |
@RI{d} is the requested decimal precision of @i{T}, |
| 541 |
and less than or equal to the value of |
| 542 |
@i{T}'Machine_Mantissa. |
| 543 |
See @RefSecNum{Model-Oriented Attributes of Floating Point Types} |
| 544 |
for further requirements |
| 545 |
that apply to implementations supporting the Numerics |
| 546 |
Annex. |
| 547 |
The value of this attribute is of the type |
| 548 |
@i{universal_integer}.]} |
| 549 |
|
| 550 |
@Attribute{Prefix=<S>, AttrName=<Model_Emin>, |
| 551 |
Text=[If the Numerics Annex is not supported, |
| 552 |
this attribute yields an implementation defined value |
| 553 |
that is greater than or equal to the value |
| 554 |
of @i{T}'Machine_Emin. |
| 555 |
See @RefSecNum{Model-Oriented Attributes of Floating Point Types} |
| 556 |
for further requirements |
| 557 |
that apply to implementations supporting the Numerics |
| 558 |
Annex. |
| 559 |
The value of this attribute is of the type |
| 560 |
@i{universal_integer}.]} |
| 561 |
|
| 562 |
@Attribute{Prefix=<S>, AttrName=<Model_Epsilon>, |
| 563 |
Text=[Yields the value |
| 564 |
@RI{T}@R('Machine_Radix)@+{1 @en @RI{T}@R('Model_Mantissa)}. The value of this |
| 565 |
attribute is of the type @i{universal_real}.]} |
| 566 |
@begin{Discussion} |
| 567 |
In most implementations, this attribute yields the absolute value of the |
| 568 |
difference between one and the smallest machine number of the type @i{T} |
| 569 |
above one which, when added to one, yields a machine number different from |
| 570 |
one. Further discussion can be found in |
| 571 |
@RefSecNum{Model-Oriented Attributes of Floating Point Types}. |
| 572 |
@end{Discussion} |
| 573 |
|
| 574 |
@Attribute{Prefix=<S>, AttrName=<Model_Small>, |
| 575 |
Text=[Yields the value |
| 576 |
@RI{T}@R('Machine_Radix)@+{@RI{T}@R('Model_Emin) @en 1}. The value of this |
| 577 |
attribute is of the type @i{universal_real}.]} |
| 578 |
@begin{Discussion} |
| 579 |
In most implementations, this attribute yields the |
| 580 |
smallest positive normalized number of the type @i{T}, |
| 581 |
i.e. the number corresponding to the positive underflow |
| 582 |
threshold. In some implementations employing a radix-complement |
| 583 |
representation for the type @i{T}, the positive underflow threshold is |
| 584 |
closer to zero than is the negative underflow threshold, with the |
| 585 |
consequence that the smallest positive normalized number does not coincide with |
| 586 |
the positive underflow threshold (i.e., it exceeds the latter). Further |
| 587 |
discussion can be found in |
| 588 |
@RefSecNum{Model-Oriented Attributes of Floating Point Types}. |
| 589 |
@end{Discussion} |
| 590 |
|
| 591 |
@AttributeLeading{Prefix=<S>, AttrName=<Model>, |
| 592 |
Text=[S'Model denotes a function with the following specification: |
| 593 |
@begin{DescExample} |
| 594 |
@key(function) S'Model (@RI{X} : @RI{T}) |
| 595 |
@key(return) @RI{T} |
| 596 |
@end{DescExample} |
| 597 |
|
| 598 |
@NoPrefix@;If the Numerics Annex is not supported, |
| 599 |
the meaning of this attribute is implementation |
| 600 |
defined; |
| 601 |
see @RefSecNum{Model-Oriented Attributes of Floating Point Types} |
| 602 |
for the definition that applies to implementations supporting |
| 603 |
the Numerics Annex.]} |
| 604 |
|
| 605 |
@Attribute{Prefix=<S>, AttrName=<Safe_First>, |
| 606 |
Text=[Yields the lower bound of the safe range |
| 607 |
(see @RefSecNum{Floating Point Types}) of the type @i{T}. |
| 608 |
If the Numerics Annex is not supported, the value |
| 609 |
of this attribute is implementation defined; |
| 610 |
see @RefSecNum{Model-Oriented Attributes of Floating Point Types} |
| 611 |
for the definition that applies to |
| 612 |
implementations supporting the Numerics Annex. The value of this attribute |
| 613 |
is of the type @i{universal_real}.]} |
| 614 |
|
| 615 |
@Attribute{Prefix=<S>, AttrName=<Safe_Last>, |
| 616 |
Text=[Yields the upper bound of the safe range |
| 617 |
(see @RefSecNum{Floating Point Types}) of the type @i{T}. |
| 618 |
If the Numerics Annex is not supported, the value |
| 619 |
of this attribute is implementation defined; |
| 620 |
see @RefSecNum{Model-Oriented Attributes of Floating Point Types} |
| 621 |
for the definition that applies to |
| 622 |
implementations supporting the Numerics Annex. The value of this attribute |
| 623 |
is of the type @i{universal_real}.]} |
| 624 |
@begin{Discussion} |
| 625 |
A predefined floating point arithmetic operation that yields a value in the |
| 626 |
safe range of its result type is guaranteed not to overflow. |
| 627 |
@end{Discussion} |
| 628 |
@begin{Honest} |
| 629 |
|
| 630 |
An exception is made for exponentiation by a negative exponent in |
| 631 |
@RefSecNum{Highest Precedence Operators}. |
| 632 |
|
| 633 |
@end{Honest} |
| 634 |
@ImplDef{The values of the Model_Mantissa, Model_Emin, Model_Epsilon, |
| 635 |
Model, Safe_First, and Safe_Last attributes, if the Numerics |
| 636 |
Annex is not supported.} |
| 637 |
@end{Description} |
| 638 |
@EndPrefixType{} |
| 639 |
@end{StaticSem} |
| 640 |
|
| 641 |
@begin{Incompatible83} |
| 642 |
@Defn{incompatibilities with Ada 83} |
| 643 |
The Epsilon and Mantissa attributes of floating point types are removed |
| 644 |
from the language and replaced by Model_Epsilon and |
| 645 |
Model_Mantissa, which may have different values (as a result of changes in the |
| 646 |
definition of model numbers); the replacement of one set of attributes by |
| 647 |
another is intended to convert what would be an inconsistent change into an |
| 648 |
incompatible change. |
| 649 |
|
| 650 |
The Emax, Small, Large, Safe_Emax, Safe_Small, and Safe_Large attributes of |
| 651 |
floating point types are removed from the language. Small and Safe_Small are |
| 652 |
collectively replaced by Model_Small, which is functionally equivalent to |
| 653 |
Safe_Small, though it may have a slightly different value. The others are |
| 654 |
collectively replaced by Safe_First and Safe_Last. Safe_Last is functionally |
| 655 |
equivalent to Safe_Large, though it may have a different value; Safe_First is |
| 656 |
comparable to the negation of Safe_Large but may differ slightly from it as |
| 657 |
well as from the negation of Safe_Last. Emax and Safe_Emax had relatively few |
| 658 |
uses in Ada 83; T'Safe_Emax can be computed in the revised language as |
| 659 |
Integer'Min(T'Exponent(T'Safe_First), T'Exponent(T'Safe_Last)). |
| 660 |
|
| 661 |
Implementations are encouraged to eliminate the incompatibilities discussed |
| 662 |
here by retaining the old attributes, during a transition period, |
| 663 |
in the form of implementation-defined attributes with their former values. |
| 664 |
@end{Incompatible83} |
| 665 |
|
| 666 |
@begin{Extend83} |
| 667 |
@Defn{extensions to Ada 83} |
| 668 |
The Model_Emin attribute is new. It is conceptually similar to the negation of |
| 669 |
Safe_Emax attribute of Ada 83, adjusted for the fact that the model numbers now |
| 670 |
have the hardware radix. It is a fundamental determinant, along with |
| 671 |
Model_Mantissa, of the set of model numbers of a type |
| 672 |
(see @RefSecNum{Model of Floating Point Arithmetic}). |
| 673 |
|
| 674 |
The Denorm and Signed_Zeros attributes are new, as are all of the |
| 675 |
primitive function attributes. |
| 676 |
@end{Extend83} |
| 677 |
|
| 678 |
@begin{Extend95} |
| 679 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00388-01]} |
| 680 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 681 |
The Machine_Rounding attribute is new.]} |
| 682 |
@end{Extend95} |
| 683 |
|
| 684 |
|
| 685 |
@LabeledSubClause{Attributes of Fixed Point Types} |
| 686 |
|
| 687 |
@begin{StaticSem} |
| 688 |
@Leading@Defn2{Term=[representation-oriented attributes], |
| 689 |
Sec=[of a fixed point subtype]} |
| 690 |
The following @i{representation-oriented} attributes are defined for |
| 691 |
@PrefixType{every subtype S of a fixed point type @i{T}}. |
| 692 |
@begin{Description} |
| 693 |
@Attribute{Prefix=<S>, AttrName=<Machine_Radix>, |
| 694 |
Text=[Yields the radix of the hardware representation of the type |
| 695 |
@i{T}. The value of this attribute is of the type @i{universal_integer}.]} |
| 696 |
|
| 697 |
@Attribute{Prefix=<S>, AttrName=<Machine_Rounds>, |
| 698 |
Text=[Yields the value True if rounding is performed on inexact |
| 699 |
results of every predefined operation that yields a result of the |
| 700 |
type @i{T}; yields the value False otherwise. |
| 701 |
The value |
| 702 |
of this attribute is of the predefined type Boolean.]} |
| 703 |
|
| 704 |
@Attribute{Prefix=<S>, AttrName=<Machine_Overflows>, |
| 705 |
Text=[Yields the value True if overflow and divide-by-zero are detected and |
| 706 |
reported by raising Constraint_Error for every predefined operation that |
| 707 |
yields a result of the type @i{T}; |
| 708 |
yields the value False otherwise. |
| 709 |
The value of |
| 710 |
this attribute is of the predefined type Boolean.]} |
| 711 |
@end{Description} |
| 712 |
@EndPrefixType{} |
| 713 |
@end{StaticSem} |
| 714 |
|
| 715 |
@begin{Incompatible83} |
| 716 |
@Defn{incompatibilities with Ada 83} |
| 717 |
The Mantissa, Large, Safe_Small, and Safe_Large attributes of fixed |
| 718 |
point types are removed from the language. |
| 719 |
|
| 720 |
Implementations are encouraged to eliminate the resulting incompatibility by |
| 721 |
retaining these attributes, during a transition period, |
| 722 |
in the form of implementation-defined attributes with their former values. |
| 723 |
@end{Incompatible83} |
| 724 |
|
| 725 |
@begin{Extend83} |
| 726 |
@Defn{extensions to Ada 83} |
| 727 |
The Machine_Radix attribute |
| 728 |
is now allowed for fixed point types. It is |
| 729 |
also specifiable in an attribute definition clause |
| 730 |
(see @RefSecNum{Machine_Radix Attribute Definition Clause}). |
| 731 |
@end{Extend83} |
| 732 |
|