summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-23 10:52:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-23 10:52:51 +0000
commit845b21064cb2638e26e11b77de58ba616fbaf183 (patch)
tree69902c170469695f589e6dfa2db718c132010ada /bignum.c
parentfd2e0e3dac68bd45fac8a51abf76408383ef0452 (diff)
update comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 80db6999b9..b53719311c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -349,6 +349,14 @@ rb_int2inum(SIGNED_VALUE n)
* 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.
+ *
+ * The buf represents negative integers as two's complement.
+ * So, the most significant bit of the most significant word,
+ * (buf[num_longs-1]>>(SIZEOF_LONG*CHAR_BIT-1)),
+ * is the sign bit: 1 means negative and 0 means zero or positive.
+ *
+ * If given size of buf (num_longs) is not enough to represent val,
+ * higier words (including a sign bit) are ignored.
*/
void
rb_big_pack(VALUE val, unsigned long *buf, long num_longs)
@@ -391,7 +399,7 @@ rb_big_pack(VALUE val, unsigned long *buf, long num_longs)
}
}
-/* See rb_big_pack comment for endianness of buf. */
+/* See rb_big_pack comment for endianness and sign of buf. */
VALUE
rb_big_unpack(unsigned long *buf, long num_longs)
{