IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Wed Apr 22, 2020 5:11 pm
Reply with quote

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
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Wed Apr 22, 2020 6:50 pm
Reply with quote

why not run a simple test program and see what happens?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Wed Apr 22, 2020 7:08 pm
Reply with quote

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???
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Wed Apr 22, 2020 7:39 pm
Reply with quote

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...)
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Thu Apr 23, 2020 6:27 am
Reply with quote

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
Back to top
View user's profile Send private message
javen777

New User


Joined: 06 Mar 2015
Posts: 31
Location: china

PostPosted: Thu Apr 23, 2020 6:28 am
Reply with quote

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.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Thu Apr 23, 2020 7:00 am
Reply with quote

www.ibm.com/support/knowledgecenter/SSY2V3_4.5.0/com.ibm.ent.pl1.zos.doc/lrm.pdf
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Thu Apr 23, 2020 2:12 pm
Reply with quote

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.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Thu Apr 23, 2020 4:53 pm
Reply with quote

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.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Thu Apr 23, 2020 7:12 pm
Reply with quote

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!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Thu Apr 23, 2020 8:10 pm
Reply with quote

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... 12.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Store the data for fixed length COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
Search our Forums:

Back to Top