For some odd reason, I'd like to be able to take a number like 534 and make 
a larger
number by repeating it 5 times, to get 534534534534534.  This is part of a 
parser,
so the two integers are passed as gmp numbers.

   gmp_init(str_repeat(gmp_strval($a),gmp_intval($b)))

sometimes works and sometimes fails.  To illustrate this consider:

   for ($i = 1; $i < 10; $i++) {
     $temp = str_repeat(gmp_strval(gmp_init($i)),8);
     echo "$temp is ",gmp_strval(gmp_init($temp)),"<br>";
   }

Yields

11111111 is 11111111
22222222 is 22222222
33333333 is 33333333
44444444 is 44444444
55555555 is 55555555
66666666 is 66666666
77777777 is 77777777
88888888 is 8
99999999 is 9

Why do the last two fail?  How can I fix this?

Note that the following works

   for ($i = 1; $i < 10; $i++) {
     $temp = str_repeat("$i",8);  # or     $temp = str_repeat($i,8);
     echo "$temp is ",gmp_strval(gmp_init($temp)),"<br>";
   }

but again I have a parser, so my input is a gmp number.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to