From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Bob Duff Newsgroups: comp.lang.ada Subject: Re: Fixed-point question Date: Sat, 27 Jun 2015 16:42:07 -0400 Organization: A noiseless patient Spider Message-ID: <876168sx28.fsf@theworld.com> References: <249bcd57-3074-4566-b8f2-03e6923bfbce@googlegroups.com> <6a104bde-67ea-48a5-a035-6be3f9235d42@googlegroups.com> <21e4185b-bc89-4940-b329-09863ad17344@googlegroups.com> <0320a865-5636-4ac6-81f7-ea56b761ce0d@googlegroups.com> <87a8vlrm9j.fsf@theworld.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="fb8695529b19d12f9fc16cf5bb865e22"; logging-data="26862"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/a0xkly32+vZVaYfSXd7JM" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:DuTtos4G/MdBAWg15Ut+S1UrlNI= sha1:8qw9/+NNTBYPTIw7GEmWd0PgmLE= Xref: news.eternal-september.org comp.lang.ada:26504 Date: 2015-06-27T16:42:07-04:00 List-Id: "Jeffrey R. Carter" writes: > Root_Real, right. I still tend to think in terms of the rules for Ada 83. ;-) > So for C1, the compiler is looking for a visible "/" that yields a result that > can be converted to Fixed_Type. Close. It's looking for a "/" that has two parameters that can be converted from universal_real -- the two literals. Or were they named numbers (I forget)? The result of those "/" ops can be anything, because type conversions don't provide an expected type (i.e. the expected type for the operand of a type conversion is "any type"). >...These include those for at least Root_Real, > Float, Duration, and Fixed_Type. 8.6(29) results in Root_Real's "/" being selected. Right. > For C2, the compiler is looking for a visible "/" that yields a result of > Fixed_Type, and only Fixed_Type's "/" does that. Well, fixed-point division is kind of magical. The individual fixed-point types don't have a "/" that takes parameters of the type and returns the same type, but there's a "/" on universal_fixed that can be used on any fixed-point types, and the two operands and result can all be of different fixed-point types. See 4.5.5(18). Similar for "*". There are also mixed fixed-integer ops for each fixed-point type. There's a rule somewhere that says the context has to provide the type of the result, so the compiler knows how much precision is needed. E.g. you can say "X := Y * Z;" but not "X := Y * Z * W;". > Is that anything close to correct? Yes, close enough to understand what the program does at run time, although not quite close enough to write a correct Ada compiler. ;-) - Bob