Re: Re: number_format() = "-0.00"
| From: | David Rodrigues | Date: | Fri, 25 Nov 2016 18:07:48 +0000 |
| Subject: | Re: Re: number_format() = "-0.00" | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97186@lists.php.net to get a copy of this message | ||
As reference, I'll put here what some languages does on this case:
Java: -0.00 (http://ideone.com/NOxen1)
Python: -0.00 (http://ideone.com/llxGHA)
Ruby: -0.00 (http://ideone.com/j3KgMd)
C++14: -0.00 (http://ideone.com/P3WdoJ)
Node.js: -0.00 (http://ideone.com/31gQgV - v0.12)
C#: 0.00 (http://ideone.com/vW0F0b)
The most languages converts to -0.00 too, except by C#.
It seems to be the correct behaviour, but by another way, it could be
confused too.
For instance, if you are treating money then you will need to check if
it is zero then abs() it to avoid this things (because $ -0.00 makes
no sense).
In all case, I should vote to accept it fix (If I could vote, of course).
2016-11-25 15:06 GMT-02:00 Craig Duncan <php@duncanc.co.uk>:
> On 25 November 2016 at 07:54, Craig Duncan <php@duncanc.co.uk> wrote:
>
>> I've submit a PR (https://github.com/php/php-src/pull/2220) to fix a bug (
>> https://bugs.php.net/bug.php?id=73581).
>>
> It sounds like opinions are divided on this, I'll draft an RFC including
> the other instances Christoph mentioned
--
David Rodrigues