Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128076 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 lists.php.net (Postfix) with ESMTPS id D2E621A00BC for ; Wed, 16 Jul 2025 11:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752665252; bh=hqqddgm8EK3a+FcQr+TNV+3wAi7KUxXzTD/blEcQbmQ=; h=Date:To:From:Subject:From; b=jY0rR5FHKTt+WSSh2KkJowSq5HcJxUTNDFfOgD0MNi1Vk8geFjBptDxYBolly5lw1 GaCrUS9NexI2qlb/TGcxYnxTHdZy/k7cK9edq4MrhhiSQKEoUC2MTtBoYWJXr3P0Rm kEwTGtzGqdo2oN47NZXbVJhkgZ9QKf0M/CojTQmZ1iRkrf+nUbdRHPvmQ4qr7Fgh1v Tb4ul22jVlw4HOd6X6W1gVF4R2j4UNUKqmW2cwnx3PHEjLoZ5IDLYl20Lm9m8JGMQ5 j7sLk9xY/MDiOV4/NRUQpyiu9E6AL3FEL24rLLq4V16xbCBg34ZngFTz2Ki/uGk21Q pimderEAC3A+Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 79D52180003 for ; Wed, 16 Jul 2025 11:27:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 16 Jul 2025 11:27:31 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id 38308e7fff4ca-32b7cf56cacso61242421fa.1 for ; Wed, 16 Jul 2025 04:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752665357; x=1753270157; darn=lists.php.net; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=F+TtGXlWsjH9qRZyFV8Fir4WCD0FUWssmREM5+YpzDc=; b=bXvetS+FBYjHJF6lHO1ucZcUIVU8G35Dr2DKU8+xbK9x7z/G0ZEDmZul32KQXfIs57 wSb3AycnHmlF7yATfmLVabJ1MbMKnglHyid5tjN19qszMoh3nba9RoMQeTARsgEzntb6 K82GfcT9AMFqNw7P3Cr/mv3YrrVzPMOnp2rAMvzw8OB0xdjx0XOZ8rfbb4+kJTEqHYmE UdSaSPeWzGGF9Ns1O7eWqPxlK2Z0y8DiupgposwKePGXqlTCCLzCGNvWu/IUvAdu+fby b/zuu8qqVDQjXXKNiFIJlcWbY+NFhoCtN5ruaKOtieUQhJZbfVoIFtZk6+ttlRsZvwa+ xKEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752665357; x=1753270157; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=F+TtGXlWsjH9qRZyFV8Fir4WCD0FUWssmREM5+YpzDc=; b=sZsC8BcGOyKGrAGv/EHK2XDh6bVznwdzk4lO3xNSzzCh2GJR8DbXjZopyNelVqW3HX lsT4vn+O/cl29TodZbpdufw//IVVCmUNDzCJfSXFs1KjLqGRGJKeaSBN99AKAZvltWeL gci9EiaqbWgFte1X62viQtCfBq6QQzICuvwoJhWZmJxCpz4MnjMGa9ffNR2Kls6yG5E7 K9qpTN2fQwin8YK8y+aCZg0AypdAT1jYkuHlxzpwfhx1LpJdD7WQJ/VUf2Lpic7L0nOL pSkqQS6A0c+smYlmjl7CuojhN8c3fuueMgzQhlFUf8yR5NmyduVy/4nbfno7EiS4Ex5n bbPg== X-Gm-Message-State: AOJu0Ywf/xhxNktuL3LQl46PhdroAIllFqncP+bCdtZltkl9+MEBa2a8 ezKxLQsiUaIlYYvQ6hKKituzqciFuQxeUEpQ4FifO19aBR6AirLeki5gfFkW5hTn X-Gm-Gg: ASbGncve0ZQ63XhsiIodoRJagyzM6DsTSgGhARFbQNoIDQ15zReV6rWf15LideasRMQ AnQ7Pd6QJ5+0w9G10bUJv2JgzwolMCOvYc+GBzIwNVTms6MV2+pgUBkK/CdpA3Spsib9NZxfb5y WpAc0d49PKOJFsC4j0OotfMABz76B3uUZH8tNZ5SK05rPi7FnYT9OM7X90IWsEIVVHx347VwztB ndeb7Ucmg3/DdxQCyaT0Mx99h7Vma2YalzZXO0eFLQ0EFt9Cr+YXyAXFJ4HyeDrTM1G7N8cIc3N SpUxbf97ncF4DUy5bhTI4vUEz1bFbN2NKnpnarNuGJGkD92i3q3LF1aJ/1LBOQ3b8QnoeIB6wPO S4TovkZ4eZnyc3fVoGBOQhFo= X-Google-Smtp-Source: AGHT+IEj009u52bZca1GrFdYH+eS0iehQQSMP2s5cpkUFvuw1mCuG/yu+uQ6Sq4KNzA1OiGXmpVlrA== X-Received: by 2002:a2e:a99f:0:b0:32a:de85:4613 with SMTP id 38308e7fff4ca-3308e546b5cmr10438111fa.23.1752665356659; Wed, 16 Jul 2025 04:29:16 -0700 (PDT) Received: from [192.168.5.10] ([62.119.254.58]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-32fa29138ebsm21439841fa.19.2025.07.16.04.29.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jul 2025 04:29:16 -0700 (PDT) Message-ID: Date: Wed, 16 Jul 2025 13:29:15 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: internals@lists.php.net Subject: [PHP-DEV] [DISCUSSION] bcmath: adding bcgetopts() and bcsetopts() to get or set bcmath options Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: quakemmo@gmail.com (Quake MMO) Hello all, Would adding a bcgetopts(): int and a bcsetopts(int $opts): void calls be useful? At this time there's no way to influence bcmath's behavior other than bcscale(). An example of option that could be configurable through this mechanism would be automatic removal of trailing / leading zeros in the results returned by bcmath. bcscale(10); echo bcadd('1', '2'); result: 3.0000000  If we could tell bcmath to strip the trailing zeros by calling bcsetopts(bcgetopts() | BC_STRIP_TRAILING_ZEROS)); , the result should be just '3'. Some options I could think of: BC_STRIP_TRAILING_ZEROS BC_STRIP_LEADING_ZEROS BC_STRIP_ZERO_INTEGER (so instead of returning 0.5, it would just return .5) The actual code to strip the trailing/leading zeros seems to already be in the library, just not exposed to the API (bc_rm_*() in libbcmath/src/rmzero.c). I'm using PHP's bcmath extensively in a performance-sensitive application and sanitizing the results in PHP is a performance sink that could be avoided this way. Thank you for your attention.