--8323328-1742129316-1122500183734
Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1742129316-1122500183=:4734"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--8323328-1742129316-1122500183734
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Thu, 28 Jul 2005, Daniel Berger wrote:

> Ara.T.Howard wrote:
>> On Thu, 28 Jul 2005, Nikolai Weibull wrote:
>> 
>>> This may be silly, considering that Fixnums are converted to Bignums if
>>> necessary, but is there no room for having MIN and MAX constants for
>>> Fixnums?  This is my C talking, but it├ď kind of nice to have these
>>> kinds of limits for certain algorithms and ┼┼efaultvalues.  Any
>>> input?,
>>>        nikolai
>> 
>> 
>> awesome!  i have this everywhere:
>> 
>>    class Fixnum
>>      N_BYTES = [42].pack('i').size
>>      N_BITS = N_BYTES * 8
>>      MAX = 2 ** (N_BITS - 2) - 1
>>      MIN = -MAX - 1
>>    end
>> 
>> cheers.
>> 
>> -a
>
> Signed or unsigned max?

maybe we are talking at cross purposes: as far as i know there is no such as an
'unsigned' Fixnum - we only have signed fixnums which loses one bit and the
VALUE/Fixnum thing which loses another.  so i assumed the OP wanted to knowhe
largest/smallest value that could be represented by a fixnum:

   harp:~ > cat a.rb
   class Fixnum
     N_BYTES = [42].pack('i').size
     N_BITS = N_BYTES * 8
     MAX = 2 ** (N_BITS - 2) - 1
     MIN = -MAX - 1
   end

   p(Fixnum::MAX)
   p(Fixnum::MAX.class)
   p((Fixnum::MAX + 1).class)

   p(Fixnum::MIN)
   p(Fixnum::MIN.class)
   p((Fixnum::MIN - 1).class)

   harp:~ > ruby a.rb
   1073741823
   Fixnum
   Bignum
   -1073741824
   Fixnum
   Bignum

make sense?

> Solaris 10:
>
> /* maxnum.c */
> #include <stdio.h>
> #include <values.h>
>
> int main(){
>   printf("Max int: %i\n", MAXINT);
>   printf("Max long: %li\n", MAXLONG);
>
>   return 0;
> }
>
> djberge@~/programming/C-568>gcc -Wall -o maxnum maxnum.c
> djberge@~/programming/C-569>./maxnum
> Max int: 2147483647
> Max long: 2147483647
>
> djberge@~/programming/C-570>gcc -Wall -m64 -o maxnum maxnum.c
> djberge@~/programming/C-571>./maxnum
> Max int: 2147483647
> Max long: 9223372036854775807

sure - but these are ints not fixnums ?

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple.  My religion is kindness.
| --Tenzin Gyatso
===============================================================================

--8323328-1742129316-1122500183734--
--8323328-1742129316-1122500183734--