Re: [RFC] [Discussion] Rounding Integers as int

From: Date: Sat, 09 Mar 2024 19:29:10 +0000
Subject: Re: [RFC] [Discussion] Rounding Integers as int
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-122595@lists.php.net to get a copy of this message
On Sat, Mar 9, 2024, at 8:00 AM, Larry Garfield wrote: ]> If there's some math reason that we cannot have those functions return > int (someone mentioned there was, but I don't really understand it and > the RFC does not explain it at all), then we should at least keep > consistency in the return type. "Sometimes I have to cast the return > value before I can actually use it in the obvious way, sometimes I > don't" is not a good situation. The round() function has to be able to return float because has an optional precision parameter. So round(3.14, 1) returns 3.1. I agree that there doesn't appear to be much of a reason that ceil() and floor() should be returning float. The documentation for ceil() says: The return value of ceil() is still of type float as the value range of float is usually bigger than that of int. Jim

« previous php.internals (#122595) next »