Skip to content
Snippets Groups Projects
Commit 18a72d68 authored by Eric Botcazou's avatar Eric Botcazou Committed by Marc Poulhiès
Browse files

ada: Use truncation for dynamic conversions from floating point to fixed point

This changes the implementation of dynamic conversions from floating-point
to ordinary fixed-point types, from rounding (to the nearest number) to
truncation (toward zero), so as to make them consistent with both static
conversions between these types and also the value of the Machine_Rounds
attribute, which is False for all fixed-point types with GNAT.

The rounding is still available under the debug switch -gnatd.N for the
sake of backward compatibility with the previous implementation.

gcc/ada/

	* debug.adb (d.N): Document new usage.
	* exp_ch4.adb (Expand_N_Type_Conversion): Copy the Float_Truncate
	flag when rewriting a floating-point to fixed-point conversion as
	a floating-point to integer conversion.
	* exp_fixd.adb: Add with and use clauses for Debug.
	(Expand_Convert_Fixed_To_Fixed): Generate a truncation in all cases
	except if the result is explicitly rounded.
	(Expand_Convert_Integer_To_Fixed): Likewise.
	(Expand_Convert_Float_To_Fixed): Generate a truncation for all kind
	of fixed-point types, except if the result is explicitly rounded, or
	-gnatd.N is specified and the type is an ordinary fixed-point type.
	* sinfo.ads (Float_Truncate): Document usage for floating-point to
	fixed-point conversions.
parent 3e62561d
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment