Bug #76824 [Opn->Nab]: number_format produces different signed result

From: Date: Thu, 30 Aug 2018 22:48:08 +0000
Subject: Bug #76824 [Opn->Nab]: number_format produces different signed result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216817@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76824&edit=1

 ID:                 76824
 Updated by:         danack@php.net
 Reported by:        jamesin dot hongkong dot 1 at gmail dot com
 Summary:            number_format produces different signed result
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 PHP Version:        7.2.9
 Block user comment: N
 Private report:     N

 New Comment:

This is a deliberate change:

http://php.net/manual/en/migration72.incompatible.php

Previously, it was possible for the number_format() function to return -0. Whilst this is perfectly
valid according to the IEEE 754 floating point specification, this oddity was not desirable for
displaying formatted numbers in a human-readable form.


Previous Comments:
------------------------------------------------------------------------
[2018-08-30 22:37:29] jamesin dot hongkong dot 1 at gmail dot com

Description:
------------
One of our integration tests failed starting with PHP 7.2+ due to a different return value from
number_format.

## Reproducible example

```
Output for 7.2.0 - 7.3.0beta2
0.00000

Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.28 - 7.1.21
-0.00000
```

https://3v4l.org/WtLF8

Test script:
---------------
print number_format( -0.000000000004566, 5 );

Expected result:
----------------
-0.00000

Actual result:
--------------
0.00000


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76824&edit=1


Thread (2 messages)

« previous php.bugs (#216817) next »