Name: Anonymous 2010-07-12 20:20
I first asked /sci/ but now I'm on the right board. I'm having some issues with a program I'm writing in perl.
The program starts with the string "9" and mod's it by a prime.
If the result is > 0 then it concatenates another 9 to the string and continues until the result is equal to 0.
It works fine until the number has 16 digits: 9999999999999999 % 17 = 1 for example. It appears the result after mod is always 1 higher than it should be when the number has more than 15 digits, regardless of the prime used.
I tried using bigint/bignum libraries but to no avail. Any ideas?
Thanks in advance.
The program starts with the string "9" and mod's it by a prime.
If the result is > 0 then it concatenates another 9 to the string and continues until the result is equal to 0.
It works fine until the number has 16 digits: 9999999999999999 % 17 = 1 for example. It appears the result after mod is always 1 higher than it should be when the number has more than 15 digits, regardless of the prime used.
I tried using bigint/bignum libraries but to no avail. Any ideas?
Thanks in advance.