# Did 1.9 deprecate NUM2INT?

**URL:** <https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562>\
**Category:** Ruby\
**Created:** [April 26, 2010, 12:21am UTC](https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562 "2010-04-26T00:21:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [April 26, 2010, 12:21am UTC](https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562/1 "2010-04-26T00:21:09Z")

</div>

I just upgraded to 1.9 and now my extension won’t compile, complaining  
that:

```
error: 'NUM2INT' was not declared in this scope

```

Did 1.9 deprecate NUM2INT? What should I use instead? Or has  
something else gone wrong?

Regards,

Jeremy H.

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [April 26, 2010, 12:40am UTC](https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562/2 "2010-04-26T00:40:27Z")

</div>

On 2010-04-25, Jeremy Henty [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) (ie. _me_)  
wrote:

> I just upgraded to 1.9 and now my extension won’t compile, complaining  
> that:
> 
> ```
> error: 'NUM2INT' was not declared in this scope
> 
> ```

OK, I compiled a test example and NUM2INT has _not_ disappeared. So  
why would a source file that used NUM2INT and compiled perfectly well  
under 1.8, suddenly fail to find NUM2INT under 1.9?

Regards,

Jeremy H.

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [April 26, 2010, 1:13am UTC](https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562/3 "2010-04-26T01:13:50Z")

</div>

Jeremy H. wrote:

> under 1.8, suddenly fail to find NUM2INT under 1.9?  
> Maybe what changed is which file includes which other files, and ruby.h  
> is no longer included? Try including it explicitly…

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [April 26, 2010, 1:15am UTC](https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562/4 "2010-04-26T01:15:35Z")

</div>

On 2010-04-25, Jeremy Henty [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) (ie. _me_)  
wrote:

> OK, I compiled a test example and NUM2INT has _not_ disappeared. So  
> why would a source file that used NUM2INT and compiled perfectly  
> well under 1.8, suddenly fail to find NUM2INT under 1.9?

I think this is solved. I appear to have a \*.h file that tries to  
maintain compatibility with the PreCambrian era by including  
workarounds in case NUM2INT is not #define-ed. I suspect that this is  
breaking because 1.9 may declare NUM2INT as a static inline instead of  
#define-ing it. Anyway, just deleting the compatibility stuff fixes  
the problem.

Of course, other stuff is still broken, but, hey, that’s what I get  
for relying on fossilised code. ☹

Regards,

Jeremy H.

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [April 26, 2010, 9:50am UTC](https://www.ruby-forum.com/t/did-1-9-deprecate-num2int/187562/5 "2010-04-26T09:50:03Z")

</div>

I wonder that there even was such a function loosing precision. If you  
still want this cast just do:

(int)NUM2LONG(value)

Wbr

Christoph

---- On Mon, 26 Apr 2010 00:20:10 +0200 Jeremy H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote ----
