Subject: Re: [Q] Bitwise operations in Scheme
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/01/12
Newsgroups: comp.lang.scheme
Message-ID: <85gtvv$nvpnu@fido.engr.sgi.com>
<see.signature@4inter.net> wrote:
+---------------
| I wonder how can I perform standard bitwise operations 
| like (in C/C++ sintax)
| &  -- bitwise AND
| |  -- bitwise OR
| ^  -- bitwise Exclusive OR
+---------------

Even though there's no standard for it, most implementations of Scheme
have the usual bitwise operations builtin, e.g., in MzScheme they're
called "bitwise-and", "bitwise-ior", "bitwise-xor", "bitwise-not", as
well as "arithmetic-shift". E.g.

	> (define foo #xffffaaaa55550000)
	> foo
	18446650247285637120
	> (number->string foo 16)
	"ffffaaaa55550000"
	> (number->string (bitwise-xor foo (arithmetic-shift foo 8)) 16)
	"ff005500ff00550000"
	> 


-Rob

-----
Rob Warnock, 8L-846		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		FAX: 650-933-0511
Mountain View, CA  94043	PP-ASEL-IA