[MacRuby-devel] [MacRuby] #159: "%d" with large integer argument gives conversion error

MacRuby ruby-noreply at macosforge.org
Tue Nov 11 21:39:27 PST 2008


#159: "%d" with large integer argument gives conversion error
---------------------------------+------------------------------------------
 Reporter:  jamis at 37signals.com  |        Owner:  lsansonetti at apple.com
     Type:  defect               |       Status:  new                  
 Priority:  major                |    Milestone:                       
Component:  MacRuby              |   Resolution:                       
 Keywords:                       |  
---------------------------------+------------------------------------------

Comment(by lsansonetti at apple.com):

 At a glance it looks like the problem is in the way we convert the
 argument to a C_INT type, to pass to the CFStringCreateWithFormat
 function, in the objc.m file - rb_str_format().

 Instead of trying to convert big fixnums or bignums to C_INT we should
 instead take a different code path and print every digit out of the
 numeric type.

 This easily reproduces when trying to print a bignum:

 {{{
 $ ./miniruby -e "p '%d' % (42**12)"
 -e:1:in `%': bignum too big to convert into `long' (RangeError)
         from -e:1:in `<main>'
 $
 }}}

 (sprintf.c is mostly unused in MacRuby, because we rely on CF for this.)

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/159#comment:1>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list