Conversion to octal
Bob Comeau
bcomeau@crossley.ca
Thu, 30 Oct 2003 11:02:32 -0400
I just had to try it:)
Here is some code that works on a 32 bit integer:
CANCEL CLEAR
DEFINE wholenum INTEGER UNSIGNED SIZE 4 PIC"^,^^^,^^^,^^^"= parm
DEFINE word1 INTEGER UNSIGNED SIZE 4 PIC "^^,^^^" =wholenum / 65536
DEFINE word2 INTEGER UNSIGNED SIZE 4 PIC "^^,^^^" =MOD(wholenum,65536)
DEFINE digit1 ZONED*1=word1[0:2]
DEFINE shift1 INTEGER UNSIGNED SIZE 4 PIC "^^,^^^" &
= MOD(word1,16384)*2 + word2[0:1]
DEFINE digit2 ZONED*1=shift1[1:3]
DEFINE digit3 ZONED*1=shift1[4:3]
DEFINE digit4 ZONED*1=shift1[7:3]
DEFINE digit5 ZONED*1=shift1[10:3]
DEFINE digit6 ZONED*1=shift1[13:3]
DEFINE digit7 ZONED*1=word2[1:3]
DEFINE digit8 ZONED*1=word2[4:3]
DEFINE digit9 ZONED*1=word2[7:3]
DEFINE digit10 ZONED*1=word2[10:3]
DEFINE digit11 ZONED*1=word2[13:3]
DEFINE octalnum CHAR*11=CHAR(digit1)+CHAR(digit2)+CHAR(digit3) &
+CHAR(digit4)+CHAR(digit5)+CHAR(digit6) &
+CHAR(digit7)+CHAR(digit8)+CHAR(digit9) &
+CHAR(digit10)+CHAR(digit11)
REPORT wholenum octalnum
It's not pretty, but it works.
These are some results:
WHOLENUM OCTALNUM
65,535 00000177777
65,536 00000200000
65,537 00000200001
4,294,967,295 37777777777
Bob Comeau
Sr. Systems Programmer Analyst
Crossley Carpet Mills Ltd.
(902)895-5491 ex 139
-----Original Message-----
From: powerh-l-admin@cube.swau.edu
[mailto:powerh-l-admin@cube.swau.edu]On Behalf Of Bruin, J.M. de
Sent: Wednesday, October 29, 2003 5:03 PM
To: 'powerh-l@lists.swau.edu'
Subject: RE: Conversion to octal
Sorry for the earlier post. This was sent unintentionally and thus too soon.
Here the complete version.
For a maximum of 134217727 (decimal i.e. 77777777 octal) you could use this:
Temp t'zu10NUMBER Zoned Unsigned Size 10
Temp t'c8OCTAL Character Size 8
Temp t'n1OCTAL8 Numeric*1
Temp t'n1OCTAL7 Numeric*1
Temp t'n1OCTAL6 Numeric*1
Temp t'n1OCTAL5 Numeric*1
Temp t'n1OCTAL4 Numeric*1
Temp t'n1OCTAL3 Numeric*1
Temp t'n1OCTAL2 Numeric*1
Temp t'n1OCTAL1 Numeric*1
Temp t'n1OCTAL0 Numeric*1
Temp t'zu10NUMBER8 Zoned Unsigned Size 10
Temp t'zu10NUMBER7 Zoned Unsigned Size 10
Temp t'zu10NUMBER6 Zoned Unsigned Size 10
Temp t'zu10NUMBER5 Zoned Unsigned Size 10
Temp t'zu10NUMBER4 Zoned Unsigned Size 10
Temp t'zu10NUMBER3 Zoned Unsigned Size 10
Temp t'zu10NUMBER2 Zoned Unsigned Size 10
Temp t'zu10NUMBER1 Zoned Unsigned Size 10
Temp t'zu10NUMBER0 Zoned Unsigned Size 10
Item t'zu10NUMBER = 134217727 (the max value as an example)
Item t'n1OCTAL8 = Floor(t'zu10NUMBER / (8^8))
Item t'zu10NUMBER8 = t'zu10NUMBER - t'n1OCTAL8 * (8^8)
Item t'n1OCTAL7 = Floor(t'zu10NUMBER8 / (8^7))
Item t'zu10NUMBER7 = t'zu10NUMBER8 - t'n1OCTAL7 * (8^7)
Item t'n1OCTAL6 = Floor(t'zu10NUMBER7 / (8^6))
Item t'zu10NUMBER6 = t'zu10NUMBER7 - t'n1OCTAL7 * (8^6)
Item t'n1OCTAL5 = Floor(t'zu10NUMBER6 / (8^5))
Item t'zu10NUMBER5 = t'zu10NUMBER6 - t'n1OCTAL7 * (8^5)
Item t'n1OCTAL4 = Floor(t'zu10NUMBER5 / (8^4))
Item t'zu10NUMBER4 = t'zu10NUMBER5 - t'n1OCTAL7 * (8^4)
Item t'n1OCTAL3 = Floor(t'zu10NUMBER4 / (8^3))
Item t'zu10NUMBER3 = t'zu10NUMBER4 - t'n1OCTAL7 * (8^3)
Item t'n1OCTAL2 = Floor(t'zu10NUMBER3 / (8^2))
Item t'zu10NUMBER2 = t'zu10NUMBER3 - t'n1OCTAL7 * (8^2)
Item t'n1OCTAL1 = Floor(t'zu10NUMBER2 / (8^1))
Item t'zu10NUMBER1 = t'zu10NUMBER2 - t'n1OCTAL7 * (8^1)
Item t'n1OCTAL0 = Floor(t'zu10NUMBER1 / (8^0))
Item t'zu10NUMBER0 = t'zu10NUMBER1 - t'n1OCTAL7 * (8^0)
Item t'c8OCTAL &
= Ascii(t'n1OCTAL8) &
+ Ascii(t'n1OCTAL7) &
+ Ascii(t'n1OCTAL6) &
+ Ascii(t'n1OCTAL5) &
+ Ascii(t'n1OCTAL4) &
+ Ascii(t'n1OCTAL3) &
+ Ascii(t'n1OCTAL2) &
+ Ascii(t'n1OCTAL1) &
+ Ascii(t'n1OCTAL0)
Mark
---------------------------------------------------------------------------
Mark de Bruin Voice : +31 15 269 69 05
TNO Automotive Fax : +31 15 257 21 04
Crash Services Laboratories GSM : +31 653 44 2145
ICT Services E-mail:bruin'at'wt.tno.nl
Room: GBS 1.1 URL
:http://www.automotive.tno.nl/
P.O. Box 6033 http://www.tno.nl/
2600 JA Delft
The Netherlands
This e-mail message including any attachment(s), is intended solely for
the addressee or addressees and is strictly confidential or otherwise
legally protected. Any views or opinions presented herein are solely
those of the author and do not necessarily represent those of TNO.
For information about this disclaimer and TNO Automotive, follow this
link http://www.automotive.tno.nl/smartsite.dws?id=886
> -----Original Message-----
> From: Mike Palandri [mailto:palandri@4j.lane.edu]
> Sent: Wednesday, October 29, 2003 19:12
> To: powerh-l@lists.swau.edu
> Subject: Re: Conversion to octal
>
>
> It's all in QTP. It's not really account creation per se,
> but a master
> file that stores VMS user names and UICs for student email
> accounts, thus
> the need to create the UIC numbers. All students that have a
> record in the
> file; a subset actually get or have accounts.
>
> When a teacher authorizes a student for email, they use a web based
> interface that pulls the student data from the file and
> creates the account
> via DCL.
>
>
> At 05:06 PM 10/29/2003 +0000, Chris Sharman wrote:
> >Mike Palandri wrote:
> >>Hi all,
> >>Anyone have a ready made piece of qtp code to convert a
> positive (base
> >>10) integer to octal?
> >
> >Presumably you're writing dcl to do this (account creation) ?
> >(I wouldn't mess with sysuaf any other way)
> >
> >How about: 'f$fao("!%I",<number>)'
> >
> >Chris
> >
> >
> >
> >-------------------------------------------------------------
> ----------
> >
> >Any views expressed in this message are those of the sender and not
> >necessarily those of CCA Group. The unauthorized use, disclosure,
> >copying or alteration of this message is forbidden. The contents of
> >this message may be confidential and/or privileged,
> copyright CCA Group
> >and are intended solely for the use of the individual or
> entity to whom
> >they are addressed. Whilst this message has been scanned, CCA Group
> >cannot guarantee that it is virus free or compatible with
> your systems
> >and accepts no responsibility for any loss or damage arising from its
> >use. The recipient is advised to run their own anti-virus
> software. If
> >you receive this message in error please contact
> >postmaster@ccagroup.co.uk immediately, destroy any copies
> and delete it
> >from your computer systems.
> >= = = = = = = = = = = = = = = = = = = = = = = = = = = =
> >Mailing list: powerh-l@lists.swau.edu
> >Subscribe: "subscribe" in message body to
> powerh-l-request@lists.swau.edu
> >Unsubscribe: "unsubscribe <password>" in message body to
> >powerh-l-request@lists.swau.edu
> >http://lists.swau.edu/mailman/listinfo/powerh-l
> >This list is closed, thus to post to the list you must be a
> subscriber.
>
>
> Mike
> .
>
> = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> Mailing list: powerh-l@lists.swau.edu
> Subscribe: "subscribe" in message body to
> powerh-l-request@lists.swau.edu
> Unsubscribe: "unsubscribe <password>" in message body to
> powerh-l-request@lists.swau.edu
> http://lists.swau.edu/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a
> subscriber.
>
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.swau.edu
Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
Unsubscribe: "unsubscribe <password>" in message body to powerh-l-request@lists.swau.edu
http://lists.swau.edu/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.