# Bignum#to\_s doesn't check base

**URL:** <https://www.ruby-forum.com/t/bignum-to-s-doesnt-check-base/123542>\
**Category:** Development\
**Created:** [December 18, 2007, 3:53pm UTC](https://www.ruby-forum.com/t/bignum-to-s-doesnt-check-base/123542 "2007-12-18T15:53:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yusuke\_ENDOH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/c89c15/32.png) [@Yusuke\_ENDOH](https://www.ruby-forum.com/u/Yusuke_ENDOH)\
**Post date:** [December 18, 2007, 3:53pm UTC](https://www.ruby-forum.com/t/bignum-to-s-doesnt-check-base/123542/1 "2007-12-18T15:53:22Z")

</div>

e$B1sF#$H?=$7$^$9!#e(B

Bignum#to\_s e$B$Ne(B base e$B$NHO0O%A%’%C%/$,F0$$$F$^$;$s!#e(B

$ ./ruby -ve ‘(2\*\*30).to\_s(1)’  
ruby 1.9.0 (2007-12-18 patchlevel 0) [i686-linux]  
-e:1:in `to_s': negative string size (or size too big) (ArgumentError) from -e:1:in`’

# Index: bignum.c

— bignum.c (revision 14305)  
+++ bignum.c (working copy)  
@@ -801,7 +801,7 @@  
};  
long bits;

- if (base \< 2 && 36 \< base)

- if (base \< 2 || 36 \< base)  
rb\_bug(“illegal radix %d”, base);

- if (base \< 2 && 36 \< base)

- if (base \< 2 || 36 \< base)  
rb\_raise(rb\_eArgError, “illegal radix %d”, base);
