Bitops. Fun. Note that we are specifically leaving strings out of this for the moment, and restricting ourselves to bool/int/bignum/float pmcs.

All bit operations pad the shorter value with 0 bits on the high bit end.

Bools are considered to have one bit. 1 if true, 0 if not.

Left shifts of integer types (bool/int/bignums which hold only integers) will promote to the next higher type if bits would otherwise go off the end.

Right shifts of integer types do *not* demote to a lower type. A bignum shifted down to 1 still produces a bigint.

Rotates on bools are meaningless (nothing happens), ints rotate at 32 or 64 bits depending on the native word size (and yeah, I know this is going to be an issue), and bignums rotate assuming they're binary numbers some multiple of 8 bits (minimum 64 bits).

Shifts of floats and bignums truncate to integers first. Shifts can be treated as multiplication or division by 2, with fractional parts dropped.

Bit and/or/xor operations on floats automatically promote them to bignums first. Bignums are truncated to integers before bitops are done on them.

Terse, but I think that's it.
--
                                Dan

--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to