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°«s kind of
> > > nice to have these kinds of limits for certain algorithms and
> > > °»default°… values.  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.

> Signed or unsigned max?

I don°«t know if you°«re trying to be clever, but as far as I know, it°«d
be the value of LONG_MAX, as that°«s how Fixnums are currently being
stored.  And I don°«t see how it matters if you°«re on a 32 or 64 bit
machine (below), as all one°«s interested in is the maximum value that
can be stored in a Fixnum (for sentinel values and so on).  Ara°«s
suggestion is a bit flawed, as it assumes a two°«s-complement arithmetic
for the MIN calculation, but who can blame him? :-)

I was perhaps not so much saying that we _must_ have MAX and MIN of
Fixnums, as a way of having good sentinel values when dealing with
Fixnums.  I was half-expecting a whole thread on duck-typing,
meta-programming, IoC, or other °»possible°… solutions to such a problem,
        nikolai

> djberge@~/programming/C-570>gcc -Wall -m64 -o maxnum maxnum.c
> djberge@~/programming/C-571>./maxnum
> Max int: 2147483647
> Max long: 9223372036854775807

-- 
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}