Re: number_format() = "-0.00"
| From: | Sherif Ramadan | Date: | Fri, 25 Nov 2016 08:58:12 +0000 |
| Subject: | Re: number_format() = "-0.00" | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97174@lists.php.net to get a copy of this message | ||
I'm pretty sure this is covered by the language reference [
http://php.net/language.types.float] as per
precision of floating point
numbers in PHP. Though I don't see much harm in adding a note with
references there to the documentation for number_format(), if that's what
you meant.
On Fri, Nov 25, 2016 at 3:21 AM, Craig Duncan <php@duncanc.co.uk> wrote:
> On 25 Nov 2016 08:11, "Rasmus Lerdorf" <rasmus@lerdorf.com> wrote:
> >
> > This doesn't seem like a bug to me. Our floating point is all IEEE 754
> and as per IEEE 754 -0.00 is the correct and expected result here.
>
> I've just read the link below and I'm inclined to agree on the technical
> reasoning.
> https://en.wikipedia.org/wiki/Signed_zero
> I'm not sure of its practical usage in PHP, I think most of our developers
> would expect "0.00", but bring consistent with IEEE 754 makes sense.
>
> Shall I add a note to the docs about this expected behaviour instead?
>