Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123814 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 700BE1A009C for ; Tue, 25 Jun 2024 13:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719320799; bh=bsI58g+XJvpSxTH09Zz1BLMhb3rH10B1BeXs+8yGGFE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=H2hal2egDRD0XwDvYZql0PjF7OXo/Pm/Nv+SNOVu6uXQvNWzL9ET+SK/TEAbp0e5T 0UnMd2fQbok1T+SFMVThs22mgpbueFMRhdoKCZSFfB0qjy2mhDLALys5ugKd0dk55Q ODVezcb+8FLBgyf394b2ERg9P8WK1xNEk0gjpzRyOKXBveQwuZDl2VCRNhyJAjx/4M cgXvoKl3RJ8n58kkeNSSDqFubAFif700G8hcoe/QZ9cV4gaYwZeSy+6OCvHqg81pke n054O6pR4x7MhPFKhIr9XDuU8DLkm3h1nX1c4fWfOntqwthfvu3mAaxipTZtpvB201 4hHKMxxRe0rsw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BEE3818007A for ; Tue, 25 Jun 2024 13:06:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from franklin.smtp.mailx.hosts.net.nz (franklin.smtp.mailx.hosts.net.nz [43.245.52.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Jun 2024 13:06:35 +0000 (UTC) Received: from 222-152-65-7-vdsl.sparkbb.co.nz ([222.152.65.7] helo=[192.168.1.67]) by franklin.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1sM5r9-003cwZ-2P for internals@lists.php.net; Wed, 26 Jun 2024 01:05:07 +1200 Message-ID: Date: Wed, 26 Jun 2024 01:04:59 +1200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Add bcdivmod() to BCMath To: internals@lists.php.net References: <90AAEBAA-30DC-40B4-AEBD-D4958753324A@sakiot.com> Content-Language: en-GB In-Reply-To: <90AAEBAA-30DC-40B4-AEBD-D4958753324A@sakiot.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Hosts-DKIM-Check: none From: weedpacket@varteg.nz (Morgan) On 2024-06-25 21:11, Saki Takamachi wrote: > Hi internals, > > I've been working on improving performance of BCMath lately, and I found that I can get the div and mod in one calculation. This is obviously faster than calculating it twice separately. > > Do you think there's a demand for this feature? > Since, when calculating either the div or the mod you basically get the other for free (as you've found), and they often go together in use (I have some number of things to distributed among some number of columns: I end up with *this many* things in each column and *this many* left over) so I can definitely see a convenience in this. Otherwise, if you want both, you essentially end up doing the same computation twice: $rem = bcmod($number, $modulus); $quot = bcdiv(bcsub($number, $rem), $modulus);