Skip to content

PHP 8.4.2 wrong round() #17253

@akademic

Description

@akademic

Description

The following code:

<?php
$numerator = 7380;
$denominator = 28800;
$precision = 2;
$result = round(($numerator / $denominator) * 100, $precision);

echo $result;

Resulted in this output:

25.62

But I expected this output instead:

25.63

Without round we get 25.625, so after round it must be 25.63

PHP Version

PHP 8.4.2

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