From: Harry Ohlsen Date: 2001-08-04T12:48:34+09:00 Subject: [ruby-talk:19102] Re: Endianness and integer indexing > For those wondering why I did this, here is a mod_exp routine > for calculating z**n % q for very large numbers such as are used > in public key encryption: Sorry, I can't answer your question, but thanks for the code. I was literally just about to write the same thing! I've just written a class to do arithmetic modulo N and exponentiation was the last thing I needed to make it complete for my purposes. I'm currently doing a number theory course at uni and decided it was a good opportunity to write some Ruby code to help me test my calculations. I love the way I can use a simple global substitution to change all of the integers in a string into "ring.element(...)" then use eval and have everything just work, saving me writing a parser for arithmetic expressions. I would think that grabbing a bit from a number would be coded to work irrespective of architecture, otherwise it wouldn't make sense to have that operation available, since Ruby is so cross-platform compatible in every other respect.