Conversion to octal

Bob Comeau bcomeau@crossley.ca
Thu, 30 Oct 2003 09:01:47 -0400


If your base10 number is not too large (16 bit integer) you can use a bit extract to get the octal digits.
Assembling them back in to a single value would easy after that:

> define wholenum INTEGER*6 UNSIGNED= parm
> define digit1 ZONED*1=wholenum[0:1]
> define digit2 ZONED*1=wholenum[1:3]
> define digit3 ZONED*1=wholenum[4:3]
> define digit4 ZONED*1=wholenum[7:3]
> define digit5 ZONED*1=wholenum[10:3]
> define digit6 ZONED*1=wholenum[13:3]
> DEFINE OCTALNUM CHAR*6=CHAR(DIGIT1)+CHAR(DIGIT2)+CHAR(DIGIT3) &
>                       +CHAR(DIGIT4)+CHAR(DIGIT5)+CHAR(DIGIT6)
> REPORT ALL
> go

WHOLENUM: 65536

30 OCT 2003                CROSSLEY CARPET MILLS LTD.                

  WHOLENUM  DIGIT1  DIGIT2  DIGIT3  DIGIT4  DIGIT5  DIGIT6  OCTALNUM

    65535     1       7       7       7       7       7      177777
    65534     1       7       7       7       7       6      177776
    29446     0       7       1       4       0       6      071406
    65536     0       0       0       0       0       0      000000
    65537     0       0       0       0       0       1      000001

This was done on an HP3000, other byte orders would require some thing a bit different I think.
Dealing with a 4 byte integer would involve a bit more work, but not much.

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 4:55 PM
To: powerh-l@lists.swau.edu
Subject: RE: Conversion to octal


FOr a maximum of 134217727 (decimal i.e. 77777777 octal) you could use this:

Temp t'zu10NUMBER Zoned Unsigned Size 10

Temp	t'n1OCTAL8 Numeric*1
Temp	t'n1OCTAL8 Numeric*1
Temp	t'n1OCTAL8 Numeric*1
Temp	t'n1OCTAL8 Numeric*1
Temp	t'n1OCTAL8 Numeric*1
Temp	t'n1OCTAL8 Numeric*1
Temp	t'n1OCTAL8 Numeric*1Temp	t'zu10OCTAL7 Zoned Unsigned Size 10
Temp	t'zu10OCTAL6 Zoned Unsigned Size 10
Temp	t'zu10OCTAL5 Zoned Unsigned Size 10
Temp	t'zu10OCTAL4 Zoned Unsigned Size 10
Temp	t'zu10OCTAL3 Zoned Unsigned Size 10
Temp	t'zu10OCTAL2 Zoned Unsigned Size 10
Temp	t'zu10OCTAL1 Zoned Unsigned Size 10
Temp	t'zu10OCTAL0 Zoned Unsigned Size 10

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'zu10OCTAL8 = Floor(t'zu10NUMBER / (8^8))
Item	t'zu10NUMBER8 = t'zu10NUMBER - t'zu10OCTAL8 * (8^8)
Item	t'zu10OCTAL7 = Floor(t'zu10NUMBER8 / (8^7))
Item	t'zu10NUMBER7 = t'zu10NUMBER8 - t'zu10OCTAL7 * (8^7)
Item	t'zu10OCTAL6 = Floor(t'zu10NUMBER7 / (8^6))
Item	t'zu10NUMBER6 = t'zu10NUMBER7 - t'zu10OCTAL7 * (8^6)
Item	t'zu10OCTAL5 = Floor(t'zu10NUMBER6 / (8^5))
Item	t'zu10NUMBER5 = t'zu10NUMBER6 - t'zu10OCTAL7 * (8^5)
Item	t'zu10OCTAL4 = Floor(t'zu10NUMBER5 / (8^4))
Item	t'zu10NUMBER4 = t'zu10NUMBER5 - t'zu10OCTAL7 * (8^4)
Item	t'zu10OCTAL3 = Floor(t'zu10NUMBER4 / (8^3))
Item	t'zu10NUMBER3 = t'zu10NUMBER4 - t'zu10OCTAL7 * (8^3)
Item	t'zu10OCTAL2 = Floor(t'zu10NUMBER3 / (8^2))
Item	t'zu10NUMBER2 = t'zu10NUMBER3 - t'zu10OCTAL7 * (8^2)
Item	t'zu10OCTAL1 = Floor(t'zu10NUMBER2 / (8^1))
Item	t'zu10NUMBER1 = t'zu10NUMBER2 - t'zu10OCTAL7 * (8^1)
Item	t'zu10OCTAL0 = Floor(t'zu10NUMBER1 / (8^0))
Item	t'zu10NUMBER0 = t'zu10NUMBER1 - t'zu10OCTAL7 * (8^0)




> -----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.