Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!paperboy!hsdndev!husc6!carlton From: carlton@husc10.harvard.edu (david carlton) Newsgroups: comp.lang.scheme Subject: Re: Logical operations on integers. Message-ID: Date: 13 Apr 91 03:46:36 GMT References: <9104090602.AA06996@cymbal.reasoning.com.> Sender: news@husc6.harvard.edu Organization: Citizens for Boysenberry Jam Lines: 50 In-reply-to: gyro@cymbal.reasoning.COM's message of 9 Apr 91 06:02:43 GMT In article <9104090602.AA06996@cymbal.reasoning.com.> gyro@cymbal.reasoning.COM (Scott Layson Burson) writes: [ I write, talking about logical operations on integers: ] Do these really make sense when operating on bignums? And and or I can buy, at least when operating on non-negative bignums, but not not. Of course, at least one of the standards mentions fixnums - maybe it could encourage implementors to stick them in if the implementation supports fixnums. I think that it would be a bit ugly, though. Of course they make sense on bignums. One way to think about it is that the sign bit of an integer, whether fixnum or bignum, is repeated infinitely to the left. Another way is simply to define (assuming two's complement) (lognot x) = (- -1 x) In one's complement, of course, LOGNOT and unary negation are the same operation. All right - I misspoke. None of them really make sense, and and or no more than not. All three of them are implementation-dependent - operations which are defined on the bits of integers depend on the representation of those bits in the computer, and since bignums have (in my opinion, at least) no one representation that is inherently superior to all others, I don't think that it really makes sense to define bitwise operations on them. Yes, you can define them in the manner that you suggested, but why define them at all? Bitwise operations are (in my experience) used mainly as a manner for packing data, and are only particularly useful if they are efficient. But in Scheme, it is a good deal less likely that these will be efficient for bignums, and since there are no guarantees about the size of numbers a given implementation will support, you can't even use them to portably pack data. (And, for that matter, packing data is something fairly foreign to the Scheme mindset.) And the only uses that I can think of them that make much sense when you are thinking of numbers as mathematical abstractions, rather than a sequence of bits, are special cases of quotient and remainder. I really don't think that the standard should define bitwise operations for bignums (and hence for integers, since fixnums haven't really made it into the standard yet) any more than it should for floating-point numbers (which at least have a representation that is encouraged, though not required, by the standard.) david carlton carlton@husc9.harvard.edu Very little immediate tradition lies behind _Le Sacre du printemps_, however, and no theory. I had only my ear to help me; I heard and I wrote what I heard. I am the vessel through which _Le Sacre_ passed. - Igor Stravinsky