# How to save 32bit and 64 bit integers in ruby extension

**URL:** <https://www.ruby-forum.com/t/how-to-save-32bit-and-64-bit-integers-in-ruby-extension/145310>\
**Category:** Ruby\
**Created:** [August 7, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/how-to-save-32bit-and-64-bit-integers-in-ruby-extension/145310 "2008-08-07T20:08:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [August 7, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/how-to-save-32bit-and-64-bit-integers-in-ruby-extension/145310/1 "2008-08-07T20:08:09Z")

</div>

Hi All,

How can I read and write 32bit or 64bit values into my C extension.

Thanks,  
-Alex

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [August 7, 2008, 8:52pm UTC](https://www.ruby-forum.com/t/how-to-save-32bit-and-64-bit-integers-in-ruby-extension/145310/2 "2008-08-07T20:52:03Z")

</div>

Alex K. wrote:

> Hi All,
> 
> How can I read and write 32bit or 64bit values into my C extension.
> 
> Thanks,  
> -Alex

Check out the ruby.h header file. Look for macros for converting C  
numeric values to Ruby numeric values, such as LONG2NUM/NUM2LONG and  
LL2NUM/NUM2LL.

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [August 7, 2008, 9:10pm UTC](https://www.ruby-forum.com/t/how-to-save-32bit-and-64-bit-integers-in-ruby-extension/145310/3 "2008-08-07T21:10:48Z")

</div>

Hi Tim,

LL2NUM/NUM2LL did the job. Since I did not see this in the README.EXT  
of  
the 1.9 code base I assumed it did not exist. Next time I will read the  
header files better.

Thanks so much!  
-Alex
