PL/I

PL/I

PL/I

 View Only
  • 1.  Data type conversion rules

    Posted Fri May 17, 2013 05:04 PM

    Where are the rules defined for converting between types of data?  I used PUT EDIT to display the contents of two variables declared as FIXED DEC(10. 2) and FIXED DEC(7,3), but I had them output as Binary values.  The first value was printed as 27 bits, and the second one as 14 bits.  The binary values are correct (after truncation of the fractional portion of the value), but I have no idea why the lengths are 27 and 14.  Thanks.

    - mb

    markboonie


  • 2.  Re: Data type conversion rules

    Posted Fri May 24, 2013 07:46 PM

    These rules are described in the LRM, but they sometimes can be complicated.

    If you could show the PUT EDIT statements you were using, I could explain how you got the results you saw

    pelderon


  • 3.  Re: Data type conversion rules

    Posted Wed May 29, 2013 01:46 AM

    Curious -- I just got notification of this post two hours ago.

    I was using:

    Dcl TempDec102 Dec (10,2);
    Dcl TempDec73  Dec (7,3);
    ...
    Put Skip Edit (TempDec102) (B);
    Put Skip Edit (TempDec73 ) (B);

    A co-worker pointed out the following:

     The documented conversion rules for PL/I in the language reference section "Converting other data attributes" use a factor of 3.32 binary digits per decimal digit, rounded up to the next digit.  The first case has 8 decimal digits before the point, giving 8*3.32 = 26.56 which rounds up to 27.  The second case has 4 decimal digits, giving 13.28 which rounds up to 14.

    That explains the behavior.  I had assumed that the compiler would do something like assign the value to a BIN(31) and display the entire 31 bits, or something like that.  My apologies for not following up by posting the answer.

    - mb

     
    markboonie


  • 4.  Re: Data type conversion rules

    Posted Sun May 26, 2013 09:05 PM

    What format did you use?

    Robin400


  • 5.  Re: Data type conversion rules

    Posted Wed May 29, 2013 01:48 AM

    As indicated in my response to the previous append, my notifications seem to be delayed -- notification for this one arrived only 15 minutes ago.

    See my response to the previous append -- thanks!

    - mb

    markboonie