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?

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

Regards,

Dan