From: Ned Konz Date: 2002-04-10T10:41:19+09:00 Subject: Re: Rotate, et al Jabari Zakiya wrote: > I know this must seem trivial, but hey, help me out here. :-) > > Also, a = 0x40000000 -- a.type -> BIGNUM > b = 0x20000000 -- b.type -> FIXNUM > > A number up to 30-bits long is type FIXNUM, while > any number > 30-bits is type BIGNUM. Why dat? > > On a 32-bit machine a = 0x80000000 will fit in a single > register and memory location. Because we also want to have object pointers fit into 32 bits. So the low bit flags the 32-bit value as a number (the numeric value is in the upper 31 bits). The low bit is, of course, used because we don't want to store objects at odd memory addresses. > Also, coming from Forth, where I have virtually complete > access and control over the machine, I was wondering if there > are any libraries or extensions in Ruby (not C, etc) that > allow you to write essentially assmebly code to make things > faster. Since Pentium (PC) class CPUs have single cycle rotate, > et al, instructions, it would be nice to somehow access them, > or at least have classes/methods compile directly to them. I wouldn't be surprised if you could write a Ruby extension in assembly language. But it's easier to use C. You could make an extension that would answer endianness and do rotations.