in reply to Re: The last 5 bits in perl
in thread The last 5 bits in perl

Note that Perls integers use only 32 (or sometimes 64) bits, and they are signed, so every number larger than 2^31 (or 2^63) is silently converted to a floating point number, loosing some precision when the number grows big:

perl -e "print 1234567890123456789012345678900 % 2" 0 perl -e "print 1234567890123456789012345678901 % 2" 0

Math::BigInt can help:

perl -MMath::BigInt -e "print Math::BigInt->new('123456789012345678901 +2345678900') % 2" 0 perl -MMath::BigInt -e "print Math::BigInt->new('123456789012345678901 +2345678901') % 2" 1

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)