From ef7d0431a0c59839f555123ccd5ad06418209c0c Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 4 Mar 2010 14:20:49 +0000 Subject: add comment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bignum.c b/bignum.c index d316a60d82..0074ba77dc 100644 --- a/bignum.c +++ b/bignum.c @@ -308,6 +308,19 @@ rb_int2inum(SIGNED_VALUE n) # error unexpected SIZEOF_LONG : SIZEOF_BDIGITS ratio #endif +/* + * buf is an array of long integers. + * buf is ordered from least significant word to most significant word. + * buf[0] is the least significant word and + * buf[num_longs-1] is the most significant word. + * This means words in buf is little endian. + * However each word in buf is native endian. + * (buf[i]&1) is the least significant bit and + * (buf[i]&(1<<(SIZEOF_LONG*CHAR_BIT-1))) is the most significant bit + * for each 0 <= i < num_longs. + * So buf is little endian at whole on a little endian machine. + * But buf is mixed endian on a big endian machine. + */ void rb_big_pack(VALUE val, unsigned long *buf, long num_longs) { @@ -349,6 +362,7 @@ rb_big_pack(VALUE val, unsigned long *buf, long num_longs) } } +/* See rb_big_pack comment for endianness of buf. */ VALUE rb_big_unpack(unsigned long *buf, long num_longs) { -- cgit v1.2.3