emery@gypsy.UUCP (10/28/86)
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
anton@idec.stc.co.uk (Anton Gibbs) (11/03/86)
In article 899, on the uncertainty of integer type conversion,
Dave Emery, concludes:
" 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...."
Obtaining the integer part of a real number strikes me as a reasonable thing
to want to do in a software engineering application. How are you meant to do
this in Ada ?
--
Regards,
Anton Gibbs <..seismo!mcvax!ukc!stc!idec!anton>
+44 438 726161 x8283