Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122669 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 6EAEE1AD8F6 for ; Sun, 17 Mar 2024 21:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710712785; bh=0/86DtguHqcHT8N2O9s8wpHtwEr7XZtgFKAaYkEhj/k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hP3DRLq02jZfBinBPaLXqD5fhLzEdnOriu6yxTo2LlR1dfAXZ2dcwZtK96gksCNAm t+kJlpKP5GTVrIbb1OCNvOAVUZVQfHu2r9sRqKKp5L2OsfzDGIarvmqiOhWmjYu664 Pe3RoSG+jrZk1Wtz2XENPhV5o99kojdtLnxrK38fqqd04TvSraTaSqAOfk2gBSqiPD rvNMZngZ1qHyuK04Geq0GKYPPGVqpmzJxfvccqSquItrGRG7qkgYF/5GAYcQM68/iz Xd4bGghAcd1DQkWIRAnIlMwFjcuMEa1JG9klyB+2/pYEnIZfnfpcGfaNwoy1kxollQ SOEiKjuOADb0A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 25B9918006B for ; Sun, 17 Mar 2024 21:59:43 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 ; Sun, 17 Mar 2024 21:59:42 +0000 (UTC) Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3c37d50adecso1265463b6e.0 for ; Sun, 17 Mar 2024 14:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710712762; x=1711317562; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0/86DtguHqcHT8N2O9s8wpHtwEr7XZtgFKAaYkEhj/k=; b=APSPZkPlG5kHy6fPWDTmmN/U8KMA/XAuIOLc1qGyBQnauNU4VmI95hmDP55J/dQPLU EwhyY9fSX8MGg06ApoOHPyOroStWorrZHmeQd6jGNy7ezeZ4+3to6SV+FPSTmoFWz+8p vQY37gYNmJa7lq5czJ/62C29LAdfj7WMZSqVMYtk1KCKfnGHK6pDdKYTxwlBEE+kgrU8 /Bi0Dm2hfSeiYZiBp9nQkpj02Fp954HQ/oSF5zO5szXTppWTlKEyJwynLtRrk+RvA5zW sQ0Jv4b9v8PnEQ/L6C3Hl4+qWLpGAtl45QEU5ZAmSyCfpnsih3HTMYDqhL7QlJv7CaSX SdSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710712762; x=1711317562; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0/86DtguHqcHT8N2O9s8wpHtwEr7XZtgFKAaYkEhj/k=; b=F23IUCye08QCOEpW9cC1rflqQlsuH4v6UAyoRamv1E1uTZfS6MBG1d8Zxn25hmMHDw NipX7uw4hF0HLNDRditIE6wKAjMPJcBJUGNsap8TddJWObG0yo7R3T2KUWmkVu6bqlfr rPQZDOOfa5MtEWkG7sdrptU+9Khc9hlIM+Yu39RVXfyfC1dX+YDKMF5ADcZnnxLtRtqe qP4dQ0LutCaZP4dPOpHq2gcP4wPSFy33yulSdXfc/R69haMyjdnp0OX5bRIKn9r4ASTV rVflk/xkgqm6EGq6rY1yzUYuTsqhSdNWsBIRTfCoG68EDmu5KmP6TUqIop4anQCF50fV 1Xyw== X-Forwarded-Encrypted: i=1; AJvYcCUSIhEDj8xB5XoynTCDqsBbqElYxPoaAvro6hvYQJE7qTYQiVJmj6rcTVkuPmazlCnC5Udjl4jWaUAfAVZrr0G+1t8Or4dB7w== X-Gm-Message-State: AOJu0YwgB+h+Q226mcIuWCOJ3TzqPBSUJkk3ga1kJFzmbyXbGAoLLQ1v HJsC4QkoKzkhQSSEcj1vVB90bs+bGvAkMDcWH6ddZjtpAHoM1205I/BZWNxOfeTkvWPKlU1A7qw T2Znur29ULZngizf7oG9qCHMfJkQ= X-Google-Smtp-Source: AGHT+IFn7ZSIRDaH7cCMLyqPyJs4uU106iBDKMceiLYqEIz77+L0luqcdla3PFqxSQvGF+i3cXjrGErztmAS7fj38qw= X-Received: by 2002:a05:6808:3384:b0:3c2:513e:92ca with SMTP id ce4-20020a056808338400b003c2513e92camr12751336oib.6.1710712762477; Sun, 17 Mar 2024 14:59:22 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <1295818d-5b01-4c94-ac21-d6645d784de4@mabe.berlin> In-Reply-To: Date: Sun, 17 Mar 2024 22:59:11 +0100 Message-ID: Subject: Re: [PHP-DEV] Re: [RFC] [Discussion] [VOTE] Rounding Integers as int To: Bob Weinand Cc: Marc Bennewitz , PHP internals Content-Type: multipart/alternative; boundary="0000000000008533cb0613e25a54" From: misterdeviling@gmail.com (Vincent Langlet) --0000000000008533cb0613e25a54 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, IMHO, the more meaningful cases of the RFC are missing : round(float, precision: >=3D 0): int|float // only cast to float for int ov= erflow ceil(float): int|float // only cast to float for int overflow floor(float): int|float // only cast to float for int overflow Calling ceil or floor on integer is meaningless, because it will return the same value. The RFC should be "Prefer int as return value when possible". Le dim. 17 mars 2024 =C3=A0 15:00, Bob Weinand a =C3= =A9crit : > On 17.3.2024 13:23:04, Marc Bennewitz wrote: > > Hello internals, > > > > I have opened the vote for the "Rounding Integers as int" RFC: > > https://wiki.php.net/rfc/integer-rounding > > > > Do to Easter weekend the vote will run for two weeks and two days > > until Tue the 2nd of April 2024. > > > > Best regards, > > > > Marc Bennewitz > > Hey Marc, > > I've voted no; it should be just changed without any force_float > parameter. Just always return int when possible (and the input was int). > If users wish to have the old behaviour, they should just explicitly > cast via (float). > > The effective BC break of that would be quite small if some things which > return float today now would return int. I cannot imagine many cases > where this would actually be unwanted. And as said, explicit (float) > casts are always possible. > > I also dislike force_float, as it cannot just be added to a function in > any code which shall be backwards compatible to 8.3 and older. It would > just emit Uncaught Error: Unknown named parameter $force_float. > > Bob > --0000000000008533cb0613e25a54 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,=C2=A0

IMHO, the more meaningful cases of the RF= C are missing :
round(flo=
at, precision: >=3D 0): int|float // only cast to float for int overflow
ceil(float): int|float // only cast to float for int overflow
floor(float): int|float // only cast to float for int overflow
Calling= ceil or floor on integer is meaningless, because it will return the same v= alue.
The RFC should be "Prefer int as return value when possible&q= uot;.

Le=C2=A0dim. 17 mars 2024 =C3=A0=C2=A015:00, Bob Weinand <bobwei9@hotmail.com> a= =C3=A9crit=C2=A0:
On 17.3.2024 13:23:04, Marc Bennewitz wrote:
> Hello internals,
>
> I have opened the vote for the "Rounding Integers as int" RF= C:
> https://wiki.php.net/rfc/integer-rounding
>
> Do to Easter weekend the vote will run for two weeks and two days
> until Tue the 2nd of April 2024.
>
> Best regards,
>
> Marc Bennewitz

Hey Marc,

I've voted no; it should be just changed without any force_float
parameter. Just always return int when possible (and the input was int). If users wish to have the old behaviour, they should just explicitly
cast via (float).

The effective BC break of that would be quite small if some things which return float today now would return int. I cannot imagine many cases
where this would actually be unwanted. And as said, explicit (float)
casts are always possible.

I also dislike force_float, as it cannot just be added to a function in any code which shall be backwards compatible to 8.3 and older. It would just emit Uncaught Error: Unknown named parameter $force_float.

Bob
--0000000000008533cb0613e25a54--