1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 00:18:23 +02:00
Files
archived-php-src/ext/json/tests/bug79908.phpt
T
Christoph M. Becker 717f1ed5e4 Fix #79908: json_encode encodes negative zero as int
Encoding a negative zero as `-0` is likely to loose the sign when
decoding (at least it does with `json_decode()`).  Therefore, we encode
it as if `JSON_PRESERVE_ZERO_FRACTION` was specified, i.e. as `-0.0`.

Closes GH-7234.
2021-07-13 15:31:07 +02:00

13 lines
230 B
PHP

--TEST--
Bug #79908 (json_encode encodes negative zero as int)
--SKIPIF--
<?php
if (!extension_loaded('json')) die("skip json extension not available");
?>
--FILE--
<?php
var_dump(json_encode(-0.));
?>
--EXPECT--
string(4) "-0.0"