[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: SQR and Bit Manipulation
- Subject: Re: SQR and Bit Manipulation
- From: Dave Thorburn <thorburn@CONL.NET>
- Date: Tue, 30 May 2000 13:13:52 -0700
Tony,
That is a great solution for creating the binary number.
How do I send a 1-byte data item containing the binary as
bits to the output file?
Is there a function that would convert the binary result into
a 1-byte numeric field?
Thanks,
Dave
>--- Original Message ---
>From: "Tony DeLia" <delia_tony@hotmail.com>
>To: thorburn@CONL.NET
>Date: 5/30/00 2:25:05 PM
>
>Dave,
>
> Here's a simplified step-by-step approach to loading your
flags as a
>consolidated bit value... flag1 represents bit 0 (highest value)
while flag
>8 represents bit 7 (lowest value)...
>
>
>! Sample Flag Settings
>let #flag1 = 0 ! 128
>let #flag2 = 0 ! 64
>let #flag3 = 0 ! 32
>let #flag4 = 1 ! 16
>let #flag5 = 1 ! 8
>let #flag6 = 1 ! 4
>let #flag7 = 1 ! 2
>let #flag8 = 1 ! 1
>
>! Accumulate Flag Bit Settings
>let #total = (#flag1 * power(2,7)) ! 128
> + (#flag2 * power(2,6)) ! 64
> + (#flag3 * power(2,5)) ! 32
> + (#flag4 * power(2,4)) ! 16
> + (#flag5 * power(2,3)) ! 8
> + (#flag6 * power(2,2)) ! 4
> + (#flag7 * power(2,1)) ! 2
> + (#flag8 * power(2,0)) ! 1
>
>! Display Results
>show 'Flag 1: ' #flag1 edit 9
>show 'Flag 2: ' #flag2 edit 9
>show 'Flag 3: ' #flag3 edit 9
>show 'Flag 4: ' #flag4 edit 9
>show 'Flag 5: ' #flag5 edit 9
>show 'Flag 6: ' #flag6 edit 9
>show 'Flag 7: ' #flag7 edit 9
>show 'Flag 8: ' #flag8 edit 9
>
>show ' Total: ' #total edit 09999999
>
>! Display Bit Total as Binary Value (TDFUNC.SQC)
>do BASE-Func('NUM_TO_BASE', 2, #total, $binary)
>
>show 'Binary: ' $binary
>
>Here's sample SQR.LOG output:
>
>Flag 1: 0
>Flag 2: 0
>Flag 3: 0
>Flag 4: 1
>Flag 5: 1
>Flag 6: 1
>Flag 7: 1
>Flag 8: 1
>Total: 00000031
>Binary: 11111
>
>You can find various SQR routines including those for BIT manipulation
on my
>site - http://www.sqrtools.com - Most are in an SQC file called
TDFUNC.SQC
>(SQR Function Library)...
>
>Regards,
>
> Tony DeLia
>
>
>
>
>
>>From: Dave Thorburn <thorburn@conl.net>
>>Reply-To: sqr-users@list.iex.net
>>To: SQR-USERS@list.iex.net
>>Subject: SQR and Bit Manipulation
>>Date: Tue, 30 May 2000 09:37:15 -0700
>>
>>I have a client department that insists on receiving information
>>represented as bits within a one-byte field.
>>
>>The values of eight one-byte flags are:
>>
>>flag Value
>>------------------------
>>flag1 0
>>flag2 0
>>flag3 0
>>flag4 0 or 1
>>flag5 0 or 1
>>flag6 0 or 1
>>flag7 0 or 1
>>flag8 0 or 1
>>
>>How do I get these values into a one-byte numeric field
>>as bits 0 - 7 (eight bit byte) ???
>>----------------
>>Sent from a WebBox - http://www.webbox.com
>>FREE Web based Email, Files, Bookmarks, Calendar, People and
>>Great Ways to Share them with Others!
>
>________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>
>
----------------
Sent from a WebBox - http://www.webbox.com
FREE Web based Email, Files, Bookmarks, Calendar, People and
Great Ways to Share them with Others!
----------------
Sent from a WebBox - http://www.webbox.com
FREE Web based Email, Files, Bookmarks, Calendar, People and
Great Ways to Share them with Others!