modular arithmetic in PHP
Posted: Wed Jan 21, 2009 9:04 am
Hi All,
In the C based languages they have a type called a ulong.
As you probably know this is a 64 bit value and can therefore hold upto 18,446,744,073,709,551,615.
If you overload this 64bit limit the ulong resets and starts from 0 again in a modular kind of way I think.
i.e. if you made a ulong called ulong1 and made it equal 18,446,744,073,709,551,615 and then you added 4 to it would end up having the value 3 (it starts counting again from zero).
Is there any such storage container in PHP that acts in this fashion, I have been checking the documentation but cannot see anything.
My only other option is to recreate a binary arithmetic system using arrays of bits and ignoring bits beyond the 64th but this seems a bit ovet the top.
Any ideas greatly appreciated.
W
In the C based languages they have a type called a ulong.
As you probably know this is a 64 bit value and can therefore hold upto 18,446,744,073,709,551,615.
If you overload this 64bit limit the ulong resets and starts from 0 again in a modular kind of way I think.
i.e. if you made a ulong called ulong1 and made it equal 18,446,744,073,709,551,615 and then you added 4 to it would end up having the value 3 (it starts counting again from zero).
Is there any such storage container in PHP that acts in this fashion, I have been checking the documentation but cannot see anything.
My only other option is to recreate a binary arithmetic system using arrays of bits and ignoring bits beyond the 64th but this seems a bit ovet the top.
Any ideas greatly appreciated.
W