joe@petsd.UUCP (Joe Orost) (08/13/87)
We had a customer enter the following to our (validated) compiler: function F(ARG : INTEGER) return INTEGER is begin return INTEGER(ARG * 33.3); end F; He was wondering why he was getting NUMERIC_ERROR whenever ARG > 3936. I was wondering why his "FORTRAN-LIKE" code compiled at all!!! What he meant to say was INTEGER(ARG * FLOAT(33.3)). So then I looked up the implicit conversion rules (4.6 (15)), and it turns out that this is legal Ada code, and the type of the constant is "DURATION", as long as no other fixed point types are declared. If other fixed point types are declared, then this expression is in error: "An implicit conversion of a convertable universal operand is applied if and only if the innermost complete context (see 8.7) determines a unique (numeric) target type for the implicit conversion, and there is no legal interpretation of this context without this conversion." This, along with: function "*" (LEFT : INTEGER; RIGHT: any_fixed_point_type) return any_fixed_point_type; along with: type DURATION is ...; causes the compiler to interpret "33.3" as type DURATION !!!!! The NUMERIC_ERROR came about because DURATION'LAST / 33.3 = 3936.096 And I thought I knew the Ada language! regards, joe -- Full-Name: Joseph M. Orost UUCP: ihnp4!vax135!petsd!joe ARPA: petsd!joe@RUTGERS.EDU Phone: (201) 758-7284 US Mail: MS 313; Concurrent Computer Corporation; 106 Apple St Tinton Falls, NJ 07724