Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to convert alphanumeric to numeric

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
dalib
Currently Banned

New User


Joined: 26 Jul 2008
Posts: 2
Location: hyderabad

PostPosted: Sat Jul 26, 2008 12:48 pm    Post subject: how to convert alphanumeric to numeric
Reply with quote

I need the difference between two alphanumeric numbers.
like if
temp-num1 = "ABCDEF"
and
temp-num2 = "ABCDEH"


I need the temp-num2 - temp-num1 to be stored in third numeric veeriable.
like

temp 9(6).

compute temp = temp-num2 - temp-num1

but since temp-num2 and temp-num1 are alphanumeric
so is there any way to get the difference between these two.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jul 26, 2008 1:12 pm    Post subject:
Reply with quote

nice theoretical homework problem.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 26, 2008 2:52 pm    Post subject:
Reply with quote

Hello,

Quote:
so is there any way to get the difference between these two.
Of course there is. . .

Now is where you have to do some work. Post the rule(s) describing how to calculate the difference. Also, rather than the "simple" example you've used (you'd expect a difference of 2, right?) you need to post what you would expect the difference between "AVRDEW" and "JYREXS" to be and how you determined that difference. Once the rule is understood, coding might follow.

Another thought is that you might describe what you are trying to accomplish and someone may have a suggestion.

Please do not post in both forums. . . This topic is locked.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Sat Jul 26, 2008 4:11 pm    Post subject: Reply to: how to convert alphanumeric to numeric
Reply with quote

given the following digits sequence

arbdgts = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

jyrexs - avrdev = 9301IX

happy multibasing computations

here is the rexx to do it

Code:

#! /bin/rexx
/*REXX- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                   */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
Trace "O"
OPTIONS "STRICT_WHITE_SPACE_COMPARISONS"
numeric digits 64
arbdgts  = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

n2 = to_dec("AVRDEV")
c2 = to_arb(n2)
say c2
n1 = to_dec("jyrexs")
c1 = to_arb(n1)
say c1
nx = n1 - n2

diff = to_arb(nx)

say "jyrexs - avrdev  = " diff

exit

to_dec:procedure expose arbdgts
   trace "O"
   parse upper arg arbn
   base  = length(arbdgts)
   mult  = 1
   decn  = 0
   do  d = length(arbn) to 1 by -1
      work = substr(arbn,d,1)
      decn = decn + mult * ( pos(work,arbdgts) - 1 )
      mult = mult * base
   end
   return decn

to_arb:procedure expose arbdgts
   trace "O"
   parse upper arg decn
   base = length(arbdgts)
   arbn = ""
   do while ( decn >= base )
      work = decn //  base
      decn = decn % base
      arbn = substr(arbdgts,work+1,1) || arbn
   end
   arbn = substr(arbdgts,decn+1,1) || arbn
   return arbn
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us