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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!bellcore!ulysses!allegra!princeton!siemens!gypsy!emery From: emery@gypsy.UUCP Newsgroups: net.lang.ada Subject: An Ada quiz on type conversions Message-ID: <38000033@gypsy.UUCP> Date: Mon, 27-Oct-86 16:33:00 EST Article-I.D.: gypsy.38000033 Posted: Mon Oct 27 16:33:00 1986 Date-Received: Tue, 28-Oct-86 19:10:54 EST Nf-ID: #N:gypsy:38000033:000:809 Nf-From: gypsy!emery Oct 27 16:33:00 1986 List-Id: quiz time, Ada fans: consider declare x : integer; y : my_float := 1.5; begin x := integer(y); end; What is the value of x? (a) 1 (b) 2 (c) constraint_error is raised (d) it depends The right answer is (d), it depends. "4.6 (a) ... The conversion of a real value to an integer type rounds to the nearest integer; if the operand is halfway between two integers (within the accuracy of the real subtype), rounding may be either up or down. " So the implementor can pick how he wants to round. This strikes me as a portability bug, but, on the other hand, I don't have a lot of sympathy for people who depend on these kinds of type conversion.... Dave Emery Siemens Research ...princeton!siemens!emery princeton!siemens!emery@seismo.css.gov