I'm missing and and or a bit. 
Author Message
 I'm missing and and or a bit.

I discovered the other night, to my disappointment, that awk doesn't have
bit-and and bit-or instructions. Things like &, &=, |, |=, ^, and ^=, to
be precise. (By the latter I mean exclusive-or, not exponentiation. Does
anybody have a use for the exponentiation operator? Just curious.)

Is there any reason these operators don't exist, or was it simply that A,
W, and K said to themselves way back "it's a text processing language,
nobody'll ever want bit-operations".

Cheers!

--
Alan Mackenzie (Munich, Germany)

(like "aa"), remove one of them (leaving, say, "a").



Tue, 08 Apr 2003 03:00:00 GMT  
 I'm missing and and or a bit.

Quote:

> I discovered the other night, to my disappointment, that awk doesn't have
> bit-and and bit-or instructions. Things like &, &=, |, |=, ^, and ^=, to
> be precise. (By the latter I mean exclusive-or, not exponentiation. Does
> anybody have a use for the exponentiation operator? Just curious.)

> Is there any reason these operators don't exist, or was it simply that A,
> W, and K said to themselves way back "it's a text processing language,
> nobody'll ever want bit-operations".

"If you want Perl, you know where to get it." ;-)

If you configure gawk-3.0.6 with the --enable-bitops switch, you will
have the undocumented functions and(), or(), xor(), lshift(), rshift()
and compl(). There's also a strtonum(), but I can't figure out how it
works.

These are all undocumented gawk extensions, so you will lose
portability.

Regards...
                Michael



Wed, 09 Apr 2003 03:00:00 GMT  
 I'm missing and and or a bit.

...

Quote:
>If you configure gawk-3.0.6 with the --enable-bitops switch, you will
>have the undocumented functions and(), or(), xor(), lshift(), rshift()
>and compl(). There's also a strtonum(), but I can't figure out how it
>works.

>These are all undocumented gawk extensions, so you will lose
>portability.

Are they documented *anywhere* (other than in the source code) ?


Wed, 09 Apr 2003 03:00:00 GMT  
 I'm missing and and or a bit.

Quote:


>...
>>If you configure gawk-3.0.6 with the --enable-bitops switch, you will
>>have the undocumented functions and(), or(), xor(), lshift(), rshift()
>>and compl(). There's also a strtonum(), but I can't figure out how it
>>works.

>>These are all undocumented gawk extensions, so you will lose
>>portability.


Quote:

>Are they documented *anywhere* (other than in the source code) ?

Not at the moment.  They will be a standard part of gawk 3.1 and will
be documented.  Basic usage is

        result = and(val1, val2) # same for or, xor
        result = lshift(val, numbits) # same for rshift
        result = comp(val) # same as C result = ~val

        if (dataval looks octal or hexadecimal)
                result = strtonum(dataval) # use with fields, etc.

Use of values outside the range of a C unsigned long for the bit
functions is undefined.  Ditto shifting more bits than in an
unsigned long.

Enjoy,

Arnold
--
Arnold Robbins                  | If There's More Than One Way To Do It,
Guest account at Emory Math/CS  | then why is there only one implementation

                                |       -- Arnold Robbins



Wed, 09 Apr 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Reading unformatted files 'bit a bit'

2. (typep (make-array 10 :element-type 'bit) '(array bit (10)))

3. If you missed EuroDevCon '98 you wont want to miss this

4. gfortran on ubuntu -- missing 32-bit library?

5. Icons missing in 'Local' mode

6. Pwm.NoteBook - 'Color' module missing

7. missing 'Scrolling-fred-dialog-item'

8. tcllib: missing subdir 'config'?

9. Missing 'libc.so.4' on linux

10. Division 32-Bit/32-Bit with 16-Bit Register

11. NEXTSTEP : Don't let your company miss it. Don't let your career miss it

12. NEXTSTEP : Don't let your company miss it. Don't let your career miss it

 

 
Powered by phpBB® Forum Software