He is looking for the nth bit from the left.
Your solution would work for the nth bit from the right.
Shouldn't take much to make it work the other way.
Bob Comeau
Sr. Systems Programmer Analyst
Crossley Carpet Mills Ltd.
(902)895-5491 ex 139
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]]On
Behalf Of John Hohn
Sent: January 27, 2006 4:05 PM
To: [log in to unmask]
Subject: Re: Suprtool Question on HP_UX
The integer arithmetic version of this (not using bit functions) goes:
Assuming this is an unsigned integer (call it num), if you want to
see if bit n is set (where n is the position from left to right, 0
relative):
if (MOD (num/2**(n+1))) / 2**n = 1, then the bit is set..
For example, in your 384 example, the 8th bit (value 256) is set if
(MOD (384/512)) / 256 = 1 (integer arith), then the 8th bit is set
(which is true).
Date sent: Fri, 27 Jan 2006 13:55:09 -0500
Send reply to: "Rao, Raghu" <[log in to unmask]>
From: "Rao, Raghu" <[log in to unmask]>
Subject: [HP3000-L] Suprtool Question on HP_UX
To: [log in to unmask]
> Hi all,
>
> I have a Suprtool question in Hp_Ux platform.
>
> I have a numeric field number(9) named CLAIM_BITS and it has values like
> 0, 2, 16, 18, 128, 130, 144, 256, 384. If I represent these in Binary,
> then it will look something like below :
>
> 0 00000000000000000000000000000000
> 2 00000000000000000000000000000010
> 16 00000000000000000000000000010000
> 18 00000000000000000000000000010010
> 128 00000000000000000000000010000000
> 130 00000000000000000000000010000010
> 144 00000000000000000000000010010000
> 256 00000000000000000000000100000000
> 384 00000000000000000000000110000000
>
> Now, I need to read the 25th bit position (from left) to identify if its
> "1" or not. According to that logic, only 128, 130, 144 and 384 from the
> above values should get selected. I have the solution to identify this
> "IF" criteria in Suprtool on Hp3000. But, how do I achieve this in
> SUPRTOOL on HP_UX ? Thanks in advance for your kind replies.
>
> Raghu Rao
>
>
> www.preferredcare.org
> "An Outstanding Member Experience," Preferred Care HMO Plans -- J. D.
Power and Associates
>
> Confidentiality Notice:
> The information contained in this electronic message is intended for the
exclusive use of the individual or entity named above and may contain
privileged or confidential information. If the reader of this message is
not the intended recipient or the employee or agent responsible to deliver
it
to the intended recipient, you are hereby notified that dissemination,
distribution or copying of this information is prohibited. If you have
received this communication in error, please notify the sender immediately
by telephone and destroy the copies you received.
>
>
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|