Skip to content

number_format rounding in 8.4 is different from older versions #18266

Open
@romanstingler

Description

@romanstingler

Description

<?php

$a = [0.06,0.0025,0.0225,0.01];

$s = array_sum($a);
echo $s . "\n";

echo number_format($s, 2, '.', '');
Output for 8.4.1 - 8.4.5
    0.095
    0.09
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.19
    0.095
    0.10

https://3v4l.org/WQVRub

PHP Version

8.4.5

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions