--- ais/ai-00267.txt 2001/10/19 01:36:44 1.3 +++ ais/ai-00267.txt 2002/05/25 03:42:18 1.4 @@ -1,12 +1,13 @@ -!standard 4.6 (33) 01-10-18 AI95-00267/03 +!standard 4.6 (33) 02-05-10 AI95-00267/04 !standard A.5.3 (41) !class amendment 01-05-14 -!status ARG approved 9-0-0 01-10-07 +!status Amendment 200Y 02-05-10 +!status ARG Approved 9-0-0 01-10-07 !status work item 01-05-14 !status received 01-05-14 !priority Medium !difficulty Easy -!subject Fast float to integer conversions +!subject Fast float-to-integer conversions !summary @@ -16,7 +17,7 @@ !problem 4.6(33) specifies the rounding for conversions from floating point types to -integer types. However, the specified rounding is different than the default +integer types. However, the specified rounding is different from the default rounding provided for conversions on many common machines. Thus, such conversions are quite expensive. @@ -25,7 +26,7 @@ of the order of 10-20%. For this application, the conversion is used to provide an index into a lookup table. The rounding used doesn't have any effect on the quality of the result (because the two table entries to which you can round in -the mid-point case are equally good), but it does affect the performance. +the midpoint case are equally good), but it does affect the performance. !proposal @@ -40,8 +41,8 @@ The function yields the integral value nearest to X. If X lies exactly halfway between two integers, one of those integers is returned, but which of them is returned is unspecified. A zero result has the sign - of X when S'Signed_Zeros is True. This function should use whatever - rounding is most efficient on the target processor. + of X when S'Signed_Zeros is True. This function provides access to + the rounding behavior which is most efficient on the target processor. AARM note: @@ -51,17 +52,17 @@ Some_Integer(Some_Float'Machine_Rounding(X)) Implementations should detect this case to generate fast code for the -conversion of X to Some_Integer. In particular, the usual Float to Integer +conversion of X to Some_Integer. In particular, the usual float-to-integer type conversion rounding code is not necessary, as the value has already been -rounded. (This applies to all of the rounding and trunctation attributes -defined in A.5.3). +rounded. (This applies to all of the rounding and truncation attributes +defined in A.5.3.) !example !discussion We considered making the return type of the attribute Integer or -Universal_Integer, but these would be inconsistent with the other rounding +universal_integer, but these would be inconsistent with the other rounding attributes defined in A.5.3. The intended use of this attribute is in a type conversion to some integer @@ -70,17 +71,18 @@ Some_Integer(Some_Float'Machine_Rounding(X)) Implementations should detect this case to generate fast code for the -conversion of X to Some_Integer. In particular, the usual Float to Integer +conversion of X to Some_Integer. In particular, the usual float-to-integer type conversion rounding code is not necessary, as the value has already been -rounded. (This probably applies to all of the rounding and trunctation -attributes defined in A.5.3). +rounded. (This probably applies to all of the rounding and truncation +attributes defined in A.5.3.) -The rounding of Machine_Rounding is purposely left unspecified. It is not -intended that users depend on the actual rounding used. (If they need a -specific mode of rounding, one of the other rounding attributes should be -used). If we had said that the rounding was implementation-defined, we would -be requiring documentation of the rounding used, which potentially would -encourage users to depend on a particular rounding. +The rounding of Machine_Rounding when the value is halfway between two integers +is purposely left unspecified. It is not intended that users depend on the +actual rounding used. (If they need a specific mode of rounding, one of the +other rounding attributes should be used.) If we had said that the rounding was +implementation-defined, we would be requiring documentation of the rounding +used, which potentially would encourage users to depend on a particular +rounding. !corrigendum A.5.3(41) @@ -92,14 +94,14 @@ @xhang<@xterm<S'Machine_Rounding> S'Machine_Rounding denotes a function with the following specification:> -@xindent< @fc<@b<function> S'Machine_Rounding (@i<X> : T)@hr - @b<return> T>> +@xcode< @fc<@b<function> S'Machine_Rounding (@i<X> : T) + @b<return> T>> @xindent<The function yields the integral value nearest to @i<X>. If @i<X> lies exactly halfway between two integers, one of those integers is returned, but which of them is returned is unspecified. A zero result has the sign -of @i<X> when S'Signed_Zeros is True. This function should use whatever -rounding is most efficient on the target processor.> +of @i<X> when S'Signed_Zeros is True. This function provides access to +the rounding behavior which is most efficient on the target processor.> !ACATS test

Questions? Ask the ACAA Technical Agent