[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Bitwise not operator.



>I've just been trying to do netmask manipulation in MacPerl (5.03r1m)
>There appear to be problems with the bitwise not of certain numbers,
>Specifically, accorind to macperl :-
>
>~ffffff00 is 7fffffff
>and
>~7fffffff is 80000000 (which is correct.)
>
>Is there something strange going on here to do with the handling
>of signed quantities and coversions? It would be nice if Perl
>behaved as expected :-)

I think the problem is that MacPerl can only count up to 2147483647. For
instance:

        if( $num < 0 ) { print "lt\n" } else { print "gt\n" }
returns:
        'gt' when $num == 2147483647    (expected)
        'lt' when $num == 2147483648    (unexpected)

Similarly if:
        $num = hex("7FFFFFFF");
        sprintf("%lx", -$num) returns 80000001 (correct)
but if:
        $num = hex("80000000")
        sprintf("%lx", -$num) returns 80000000 (H'mmm)

In the last case it should return FF80000000, but can't manage the first
"FF" I believe.

I should add this is with MacPerl 68K.

Alan Fry