Hi all, I'm working on implementing a correct Fortran rounding (rounding to nearest-integer, with half integer values rounded to the integer of maximum absolute value) in the Fortran front-end, following ada/trans.c (convert_with_check) and http://gcc.gnu.org/ml/fortran/2005-04/msg00139.html
The code Ada uses to do it has the following comments: /* The following calculations depend on proper rounding to even of each arithmetic operation. In order to prevent excess precision from spoiling this property, use the widest hardware floating-point type. FIXME: For maximum efficiency, this should only be done for machines and types where intermediates may have extra precision. */ calc_type = longest_float_type_node; /* FIXME: Should not have padding in the first place */ if (TREE_CODE (calc_type) == RECORD_TYPE && TYPE_IS_PADDING_P (calc_type)) calc_type = TREE_TYPE (TYPE_FIELDS (calc_type)); I have the three following questions, probably best directed to middle-end experts and Ada maintainers: * How can I know the longest float type? My first patch uses the long_double_type_node unconditionally, but it surely isn't a generic solution * How can I determine if a given type may have extra precision? * What is this padding code doing, and is it necessary? Thanks, FX