Hi Vincent,

On 17.03.24 22:59, Vincent Langlet wrote:
Hi,

IMHO, the more meaningful cases of the RFC are missing :
round(float, precision: >= 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 value.
The RFC should be "Prefer int as return value when possible".

I do believe it's important to avoid unnecessary casts as much as possible and leave it up to the user making cast explicit than implicit else the behavior gets quite unpredictable.

Implicitly casting to float only happens on int underflow/overflow. Implicitly casting to int will never happen.

As you say "Calling ceil or floor on integer is meaningless, because it will return the same value." this is already noted in the RFC and the functions will be a no-op in this case.

Best regards,
Marc

Attachment: OpenPGP_0x3936ABF753BC88CE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to