Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucbvax.ARPA Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!ucbvax!info-vax From: info-vax@ucbvax.ARPA Newsgroups: fa.info-vax Subject: Re: Possible VAX/VMS PL/I bug Message-ID: <4884@ucbvax.ARPA> Date: Sat, 16-Feb-85 19:24:37 EST Article-I.D.: ucbvax.4884 Posted: Sat Feb 16 19:24:37 1985 Date-Received: Mon, 18-Feb-85 05:41:24 EST Sender: daemon@ucbvax.ARPA Organization: University of California at Berkeley Lines: 33 From: hplabs!sdcrdcf!darrelj@BERKELEY (Darrel VanBuer) PL/I will make lots of implicit conversions for you (probably too many), and I much prefer to be warned on them, since they may indicate errors like a misspelled variable. A returns declaration guarantees what type is the result of any such conversions (the same is true in a more limited way in Fortran). The following fragment will usually "work" in PL/I the way you'd expect, but really ought to draw several warnings, just as the RETURN does. DCL ANS CHAR(20) VARYING; ANS = SQRT('101011'B * 4.5E1); The way you get rid of the warnings is thru uses of the pseudo functions FIX and FLOAT for numbers, and PUT STRING(ANS) ... for the numeric to string conversion. Just because PL/I is willing to and has rules for all kinds of strange implicit conversions doesn't mean it isn't bad form. Some of the conversions can be fairly expensive. Better to at least SAY your knowingly doing something funny. Some instances of the conversions also give unexpected results. The expression 1/3 + 25 results in 5.33333333333333 in IBM 360 PL/I when you follow all the (explicitly given) coercion rules (it also generates an OVERFLOW exception if enabled. The reason is that all those constants are decimal (not binary, and makes no difference if you assign result to a binary variable), the rules say the result of 1/3 will be DECIMAL(15,14) precision and for the add will also be (15,14)--it ought to be 16,14 but 15 is the limit (and even with a different limit, the 1/3 will still be (n,n-1) and will still overflow the ADD. Darrel J. Van Buer, PhD System Development Corp. 2500 Colorado Ave Santa Monica, CA 90406 (213)820-4111 x5449 ...{allegra,burdvax,cbosgd,hplabs,ihnp4,orstcs,sdcsvax,ucla-cs,akgua} !sdcrdcf!darrelj VANBUER@USC-ECL.ARPA