# Rinda and ruby numbers

**URL:** <https://www.ruby-forum.com/t/rinda-and-ruby-numbers/66648>\
**Category:** Ruby\
**Created:** [August 28, 2006, 6:30am UTC](https://www.ruby-forum.com/t/rinda-and-ruby-numbers/66648 "2006-08-28T06:30:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xaea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/db5fbb/32.png) [@xaea](https://www.ruby-forum.com/u/xaea)\
**Post date:** [August 28, 2006, 6:30am UTC](https://www.ruby-forum.com/t/rinda-and-ruby-numbers/66648/1 "2006-08-28T06:30:36Z")

</div>

1. is there any way to pre-allocate memory used by tuplespace, or is the  
memory used automatically set depending on the machine’s free memory?

2. it is said that ruby numbers’ sizes aren’t fixed, and depend on  
system’s free memory. is there any ruby switch or something that can set  
the sizes statically, and not “manually” by bitwising the numbers?

---

<div class="post-metadata">

**Author:** ![xaea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/db5fbb/32.png) [@xaea](https://www.ruby-forum.com/u/xaea)\
**Post date:** [August 28, 2006, 9:52am UTC](https://www.ruby-forum.com/t/rinda-and-ruby-numbers/66648/2 "2006-08-28T09:52:11Z")

</div>

Memory allocation is not your concern unless you are using the C API.  
Memory is allocated as required and dead objects are garbage collected.  
Although process memory will not yet shrink in Ruby (it doesn’t have a  
compacting garbage collector) it will be reused for new objects. Ruby  
numbers will automatically generate instances of Bignum for any  
operation which would overflow the range of a Fixnum object. The effect  
of this is they grow as required to fit large numbers.

What exactly do you want to do? Maybe we can help if you explain your  
problem.

---

<div class="post-metadata">

**Author:** ![xaea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/db5fbb/32.png) [@xaea](https://www.ruby-forum.com/u/xaea)\
**Post date:** [August 30, 2006, 3:04am UTC](https://www.ruby-forum.com/t/rinda-and-ruby-numbers/66648/3 "2006-08-30T03:04:31Z")

</div>

i am trying to control the behaviour of my tuplespace items (objects put  
into tuplespace) by assuring that the sizes of the items are static  
(i.e. numbers won’t change class into Bignum from Fixnum, etc). so aside  
bitwising, is there any other method to manipulate those numbers (ruby  
switches maybe)?

Timothy G. wrote:

> Memory allocation is not your concern unless you are using the C API.  
> Memory is allocated as required and dead objects are garbage collected.  
> Although process memory will not yet shrink in Ruby (it doesn’t have a  
> compacting garbage collector) it will be reused for new objects. Ruby  
> numbers will automatically generate instances of Bignum for any  
> operation which would overflow the range of a Fixnum object. The effect  
> of this is they grow as required to fit large numbers.
> 
> What exactly do you want to do? Maybe we can help if you explain your  
> problem.

---

<div class="post-metadata">

**Author:** ![xaea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/db5fbb/32.png) [@xaea](https://www.ruby-forum.com/u/xaea)\
**Post date:** [August 31, 2006, 1:48am UTC](https://www.ruby-forum.com/t/rinda-and-ruby-numbers/66648/4 "2006-08-31T01:48:37Z")

</div>

On Aug 29, 2006, at 6:04 PM, Xaea Alvein wrote:

> > of this is they grow as required to fit large numbers.  
> > switches maybe)?  
> > A Fixnum is always a Fixnum, and a Bignum is always a Bignum. If you  
> > subtract one from a Bignum at the Bignum/Fixnum boundary you’ll get a  
> > Fixnum, and vice versa. The number won’t change class underneath you  
> > (5 will always be a Fixnum, never a Bignum).

If you want to move the boundary switch from or to a 32 bit machine.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)

A: Yes  
Q: Is top-posting bad?  
? Derek Milhous Zumsteg
