FYI, I just tried with 1.8.7 and got the same result. Regards, Sylvain ----- Message d'origine ---- > De : Sylvain HENRY <hsyl20 / yahoo.fr> > : ruby-core / ruby-lang.org > Envoyle : Lundi, 2 Juin 2008, 1h07mn 53s > Objet : Problem with NUM2INT > > Hi, > > I startedriting my own extension for Ruby in C and I encountered what may be a > bug with NUM2INT. > > I just wanted to convert a Ruby VALUE to a C Int. The problem is that I don't > get the same value whether I use NUM2INT, rb_num2int or NUM2LONG. > > For instance: > static VALUE rb_video_stream_new(VALUE self, VALUE vindex) { > long index = NUM2INT(vindex); > printf("vindex %d, index %d\n", vindex, index); > long index2 = rb_num2int(vindex); > printf("vindex %d, index %d\n", vindex, index2); > long index3 = NUM2LONG(vindex); > printf("vindex %d,ndex %d\n", vindex, index3); > return Qnil; > } > > void Init_video_stream(VALUE dae_mod) { > VALUE video_stream_class = rb_define_class_under(dae_mod, "Testo", > rb_cObject); > rb_define_singleton_method(video_stream_class, "new", rb_video_stream_new, > 1); > } >0A> In ruby, Testo.new(100) will print: > vindex 201, index 101 > vindex 201, index 100 > vindex 201, index 101 > > > I use Ruby 1.8.6114), the last one in Gentoo. See attached file for the source > code. > Maybe this problem is resolved in 1.8.7? > > Regards, > Sylvain > > > __________________________________________________ > Do You Yahoo!? > En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible > contre les messages non sollicitñÔ > http://mail.yahoo.fr Yahoo! Mail __________________________________________________ Do You Yahoo!? En finir avec le spam? Yahoo! Mail vous offre laeilleure protection possible contre les messages non sollicitñÔ http://mail.yahoo.fr Yahoo! Mail