Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
comparasion between BIN FIXED(63) and CHAR(16)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: comparasion between BIN FIXED(63) and CHAR(16)
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

Senior Member


Joined: 14 Mar 2007
Posts: 10690
Location: italy

PostPosted: Wed Apr 22, 2020 6:50 pm    Post subject: Reply to: comparasion between BIN FIXED(63) and CHAR(16)
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

Active Member


Joined: 29 Apr 2008
Posts: 801
Location: Maryland

PostPosted: Wed Apr 22, 2020 7:08 pm    Post subject: Re: comparasion between BIN FIXED(63) and CHAR(16)
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: 1206
Location: Vilnius, Lithuania

PostPosted: Wed Apr 22, 2020 7:39 pm    Post subject:
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    Post subject:
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    Post subject: Re: comparasion between BIN FIXED(63) and CHAR(16)
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: 313
Location: Inside the SPEW (Cincinnati OH USA)

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

https://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: 2365
Location: Hampshire, UK

PostPosted: Thu Apr 23, 2020 2:12 pm    Post subject: Reply to: comparasion between BIN FIXED(63) and CHAR(16)
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

Active Member


Joined: 29 Apr 2008
Posts: 801
Location: Maryland

PostPosted: Thu Apr 23, 2020 4:53 pm    Post subject: Re: comparasion between BIN FIXED(63) and CHAR(16)
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: 1206
Location: Vilnius, Lithuania

PostPosted: Thu Apr 23, 2020 7:12 pm    Post subject: Re: comparasion between BIN FIXED(63) and CHAR(16)
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

Active Member


Joined: 29 Apr 2008
Posts: 801
Location: Maryland

PostPosted: Thu Apr 23, 2020 8:10 pm    Post subject: Re: comparasion between BIN FIXED(63) and CHAR(16)
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts how to convert Hex String t char hex Martylin PL/I & Assembler 6 Fri Jun 05, 2020 7:45 pm
No new posts Insert System Runtime in HEADER In SY... Rick Ryan SYNCSORT 9 Tue May 26, 2020 9:01 pm
No new posts how to do bit operations from CHAR Martylin PL/I & Assembler 3 Wed May 13, 2020 8:27 pm
No new posts Variable length(Pipe delimter) to Fix... SreekanthMada DFSORT/ICETOOL 8 Mon Jan 06, 2020 4:44 pm
No new posts from CSV to fixed Ron Klop DFSORT/ICETOOL 7 Thu Feb 07, 2019 8:10 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us