# comparasion between BIN FIXED(63) and CHAR(16)

Author Message
javen777

New User

Joined: 06 Mar 2015
Posts: 31
Location: china

 Posted: Wed Apr 22, 2020 5:11 pm i have 2 parameters defined in a PL/I programe One type is BIN FIXED(63) the other one's type is CHAR(16) may i know how to compare the value between them? thanks
enrico-sorichetti

Superior Member

Joined: 14 Mar 2007
Posts: 10801
Location: italy

 Posted: Wed Apr 22, 2020 6:50 pm why not run a simple test program and see what happens?
sergeyken
Warnings : 2

Senior Member

Joined: 29 Apr 2008
Posts: 1188

Posted: Wed Apr 22, 2020 7:08 pm

 javen777 wrote: i have 2 parameters defined in a PL/I programe One type is BIN FIXED(63) the other one's type is CHAR(16) may i know how to compare the value between them? thanks

How do you imagine any comparison between those two values:
 Code: '1010101010101010101010101010101010101010101010101010101010101010'B and 'ABCDEFGHIJKLMNOP'

What result do you expect???
prino
Warnings : 1

Senior Member

Joined: 07 Feb 2009
Posts: 1263
Location: Vilnius, Lithuania

Posted: Wed Apr 22, 2020 7:39 pm

Dumbass, why don't you RTFM:

 Code: PICSPEC The PICSPEC built-in function casts data from CHARACTER to PICTURE type. >>- PICSPEC ( x , y ) ->< x Expression. y Picture specification. The expression x must be CHARACTER NONVARYING with a length known at compile time. y must be a character literal that specifies a valid PICTURE with an external representation that has the same length as the first argument. The result has the PICTURE type specified by the second argument. Unlike the EDIT built-in function, no conversion is done and no checks are made to see if the first argument holds data valid for the picture. Like the UNSPEC built-in function, only the "type" of the data is changed. So, for example given PICSPEC(x,'(5)9'), x must be CHAR(5) (since while the picture specification '(5)9' was 4 characters in length, its external representation requires 5 characters), but x will not be checked to see if it actually contains 5 numeric digits. A statement of the N = N + PICSPEC(X,'(5)9') will not cause x to be converted from CHAR to PIC'(5)9', a conversion that would require a library call, but will cause the contents of x to be treated as if it were declared as PIC'(5)9'.

And in general PL/I can compare anything with anything, the manual contains a section on how the various datatypes are converted to other ones.

And for what it's worth, a FIXED BIN(63) with a value of 1 will not compare equal (using PICSPEC) with a CHAR(16) containing '1' (whereas directly comparing them may tell you they are actually equal...)
javen777

New User

Joined: 06 Mar 2015
Posts: 31
Location: china

Posted: Thu Apr 23, 2020 6:27 am

prino wrote:
Dumbass, why don't you RTFM:

 Code: PICSPEC The PICSPEC built-in function casts data from CHARACTER to PICTURE type. >>- PICSPEC ( x , y ) ->< x Expression. y Picture specification. The expression x must be CHARACTER NONVARYING with a length known at compile time. y must be a character literal that specifies a valid PICTURE with an external representation that has the same length as the first argument. The result has the PICTURE type specified by the second argument. Unlike the EDIT built-in function, no conversion is done and no checks are made to see if the first argument holds data valid for the picture. Like the UNSPEC built-in function, only the "type" of the data is changed. So, for example given PICSPEC(x,'(5)9'), x must be CHAR(5) (since while the picture specification '(5)9' was 4 characters in length, its external representation requires 5 characters), but x will not be checked to see if it actually contains 5 numeric digits. A statement of the N = N + PICSPEC(X,'(5)9') will not cause x to be converted from CHAR to PIC'(5)9', a conversion that would require a library call, but will cause the contents of x to be treated as if it were declared as PIC'(5)9'.

And in general PL/I can compare anything with anything, the manual contains a section on how the various datatypes are converted to other ones.

And for what it's worth, a FIXED BIN(63) with a value of 1 will not compare equal (using PICSPEC) with a CHAR(16) containing '1' (whereas directly comparing them may tell you they are actually equal...)

thanks, may i have the manual link plz ? i searched the knowledge center but didn't find anything related
javen777

New User

Joined: 06 Mar 2015
Posts: 31
Location: china

Posted: Thu Apr 23, 2020 6:28 am

sergeyken wrote:
 javen777 wrote: i have 2 parameters defined in a PL/I programe One type is BIN FIXED(63) the other one's type is CHAR(16) may i know how to compare the value between them? thanks

How do you imagine any comparison between those two values:
 Code: '1010101010101010101010101010101010101010101010101010101010101010'B and 'ABCDEFGHIJKLMNOP'

What result do you expect???

i know , that's why i posted here since i am a new bee.
dneufarth

Active User

Joined: 27 Apr 2005
Posts: 329
Location: Inside the SPEW (Cincinnati OH USA)

 Posted: Thu Apr 23, 2020 7:00 am www.ibm.com/support/knowledgecenter/SSY2V3_4.5.0/com.ibm.ent.pl1.zos.doc/lrm.pdf
Nic Clouston

Global Moderator

Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

 Posted: Thu Apr 23, 2020 2:12 pm There are links to manuals at the top of every page of the forum. Also you can use Google to find the manual that you want . In this case a search for "pl/i language reference manual" would get you a link. You would also need the Programmers Guide.
sergeyken
Warnings : 2

Senior Member

Joined: 29 Apr 2008
Posts: 1188

Posted: Thu Apr 23, 2020 4:53 pm

javen777 wrote:
sergeyken wrote:
How do you imagine any comparison between those two values:
 Code: '1010101010101010101010101010101010101010101010101010101010101010'B and 'ABCDEFGHIJKLMNOP'

What result do you expect???

i know , that's why i posted here since i am a new bee.

No one except yourself is able to guess: what are your intentions in planned "comparison" of two different entities?

1) PL/I does not allow straightforward comparison of incompatible datatypes (unlike let's say REXX, e.a.)

2) before comparison of incompatible entities they must be converted to compatible types, using either some of 100+ PL/I built-in functions, or a special one.

3) the required type of conversion depends exclusively on the semantics of your application. There are multiple options:
* convert both values to either binary, or hexadecimal strings, and compare them as string values;
* convert binary value to character (printable) string, and compare as string values; then: alignment, leading zeroes, decimal point, plus/minus characters, comma-separators etc. may affect the result of comparison;
* attempt to convert character string to corresponding binary value (if possible?); then compare two numeric values as whole numbers;
* 1000+ others, more sophisticated conversions;

You are the only person at this forum who can clarify these issues.
prino
Warnings : 1

Senior Member

Joined: 07 Feb 2009
Posts: 1263
Location: Vilnius, Lithuania

Posted: Thu Apr 23, 2020 7:12 pm

 sergeyken wrote: 1) PL/I does not allow straightforward comparison of incompatible datatypes (unlike let's say REXX, e.a.)

It does. You may get a lot of W-type messages about data conversions that will be done by subroutine calls, but as I mentioned before, the manuals (used to?) contain a pretty extensive section on what's converted to what and how!
sergeyken
Warnings : 2

Senior Member

Joined: 29 Apr 2008
Posts: 1188

Posted: Thu Apr 23, 2020 8:10 pm

prino wrote:
 sergeyken wrote: 1) PL/I does not allow straightforward comparison of incompatible datatypes (unlike let's say REXX, e.a.)

It does. You may get a lot of W-type messages about data conversions that will be done by subroutine calls, but as I mentioned before, the manuals (used to?) contain a pretty extensive section on what's converted to what and how!

Default conversion and comparison between BINARY and CHARACTER, provided in PL/I, is useless in real life.

Especially when the author has no idea about his own intentions...
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics COnvert a column with mix of hex ,cha... DB2 5 How do i verify the char field is hav... PL/I & Assembler 1 how to convert Hex String t char hex PL/I & Assembler 6 Insert System Runtime in HEADER In SY... SYNCSORT 9 how to do bit operations from CHAR PL/I & Assembler 3
Search our Forums: