Re: Introducing 2 new modes to round function

From: Date: Fri, 21 Jul 2023 20:04:55 +0000
Subject: Re: Introducing 2 new modes to round function
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-120858@lists.php.net to get a copy of this message
On Jul 21, 2023, at 12:38, Marco Pivetta <ocramius@gmail.com> wrote: > Hey Jorg, > > What is the reason for using this over these? > > * https://www.php.net/manual/en/function.ceil.php > * https://www.php.net/manual/en/function.floor.php floor() and ceil() don't have a $precision parameter. What could be even more useful, however, would be to add modes which always round towards / away from zero. I suspect the commenter intending to use these modes in accounting would prefer these semantics over an implementation (like theirs) which always rounds to numerically higher / lower values. It might also be appropriate to use more specific terminology for these modes, e.g. PHP_ROUND_FLOOR/_CEIL and PHP_ROUND_TO_ZERO/_AWAY_FROM_ZERO, rather than the ambiguous PHP_ROUND_DOWN.

« previous php.internals (#120858) next »