Req #79246 [Opn->Csd]: str_repeat breaks due to limit on argument

From: Date: Sat, 08 Feb 2020 08:19:14 +0000
Subject: Req #79246 [Opn->Csd]: str_repeat breaks due to limit on argument
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225442@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79246&edit=1 ID: 79246 User updated by: tiruchi_eral at outlook dot com Reported by: tiruchi_eral at outlook dot com Summary: str_repeat breaks due to limit on argument -Status: Open +Status: Closed Type: Feature/Change Request Package: *General Issues PHP Version: 7.4.2 Block user comment: N Private report: N New Comment: arbitrary precision data type would solve this. like poorly named Integer in Haskell. In my defence before I forget, among a long list of other things, I tried enabling gmp extension and using gmp_abs to create what was required, it didn't work. gmp doesn't have a alternative for str_repeat, same for bcmath. Closing this, as I am not sure if php has something for this somewhere OOB. enabling php extensions doesn't count as OOB, and is not easy due to poor official documentation. My goal was to complete a program quickly for solving(https://www.hackerrank.com/challenges/repeated-string/problem), without implementing orthogonal stuff. apologies if I made any errors in reporting this issue or any other errors in general. Previous Comments: ------------------------------------------------------------------------ [2020-02-08 07:50:18] tiruchi_eral at outlook dot com Description: ------------ --- From manual page: https://php.net/function.str-repeat --- Test script: --------------- <?php $n = 1_000_000_000_000; $s = "abab"; print_r(repeatString($s, $n) ); Expected result: ---------------- see the string repeated $n times. Actual result: -------------- PHP Warning: str_repeat() expects parameter 2 to be int, float given ... Warning: str_repeat() expects parameter 2 to be int, float given ... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79246&edit=1

« previous php.bugs (#225442) next »